Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 11 additions & 16 deletions src/Config/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

use Quantum\Config\Exceptions\ConfigException;
use Quantum\Loader\Exceptions\LoaderException;
use Quantum\Contracts\StorageInterface;
use Quantum\Config\Contracts\ConfigInterface;
use Quantum\Di\Exceptions\DiException;
use Dflydev\DotAccessData\Data;
use Quantum\Loader\Loader;
Expand All @@ -30,7 +30,7 @@
* Class Config
* @package Quantum\Config
*/
class Config implements StorageInterface
class Config implements ConfigInterface
{
private static ?Data $configs = null;

Expand All @@ -49,10 +49,8 @@ public static function getInstance(): Config
}

/**
* Loads configuration
* @throws ConfigException
* @throws DiException
* @throws ReflectionException
* @inheritDoc
* @throws DiException|LoaderException|ReflectionException
*/
public function load(Setup $setup): void
{
Expand All @@ -64,7 +62,7 @@ public function load(Setup $setup): void
}

/**
* Imports new config file
* @inheritDoc
* @throws ConfigException
* @throws DiException
* @throws ReflectionException|LoaderException
Expand All @@ -85,9 +83,7 @@ public function import(Setup $setup): void
}

/**
* Gets the config item by given key
* @param mixed $default
* @return mixed|null
* @inheritDoc
*/
public function get(string $key, $default = null)
{
Expand All @@ -99,24 +95,23 @@ public function get(string $key, $default = null)
}

/**
* Get all configs
* @inheritDoc
*/
public function all(): ?Data
{
return self::$configs;
}

/**
* Checks config data
* @inheritDoc
*/
public function has(string $key): bool
{
return self::$configs && !empty(self::$configs->has($key));
}

/**
* Sets new value
* @param mixed $value
* @inheritDoc
*/
public function set(string $key, $value): void
{
Expand All @@ -128,15 +123,15 @@ public function set(string $key, $value): void
}

/**
* Removes the data from config
* @inheritDoc
*/
public function delete(string $key): void
{
self::$configs && self::$configs->remove($key);
}

/**
* Deletes whole config data
* @inheritDoc
*/
public function flush(): void
{
Expand Down
70 changes: 70 additions & 0 deletions src/Config/Contracts/ConfigInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

declare(strict_types=1);

/**
* Quantum PHP Framework
*
* An open source software development framework for PHP
*
* @package Quantum
* @author Arman Ag. <arman.ag@softberg.org>
* @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
* @link http://quantum.softberg.org/
* @since 3.0.0
*/

namespace Quantum\Config\Contracts;

use Quantum\Loader\Setup;

/**
* Interface ConfigInterface
* @package Quantum\Config
*/
interface ConfigInterface
{
/**
* Gets whole storage data
* @return mixed
*/
public function all();

/**
* Checks if the storage contains a key
*/
public function has(string $key): bool;

/**
* Gets the value from the storage by given key
* @param mixed $default
* @return mixed|null
*/
public function get(string $key, $default = null);

/**
* Sets storage value with the given key
* @param mixed $value
*/
public function set(string $key, $value): void;

/**
* Deletes the data from the storage by given key
*/
public function delete(string $key): void;

/**
* Deletes whole storage data
*/
public function flush(): void;

/**
* Loads configuration
*/
public function load(Setup $setup): void;

/**
* Imports new config file
*/
public function import(Setup $setup): void;
}
28 changes: 23 additions & 5 deletions src/Cookie/Contracts/CookieStorageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,42 @@

namespace Quantum\Cookie\Contracts;

use Quantum\Contracts\StorageInterface;

/**
* Interface CookieStorageInterface
* @package Quantum\Cookie
*/
interface CookieStorageInterface extends StorageInterface
interface CookieStorageInterface
{
/**
* Gets whole storage data
* @return mixed
*/
public function all();

/**
* Checks if the storage contains a key
*/
public function has(string $key): bool;

/**
* Gets the value from the storage by given key
* @return mixed|null
*/
public function get(string $key);

/**
* Sets data by given key
* @param mixed $value
* @return void
*/
public function set(string $key, $value = '', int $time = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false): void;

/**
* Deletes data by given key
* @return void
*/
public function delete(string $key, string $path = '/'): void;

/**
* Deletes whole storage data
*/
public function flush(): void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,19 @@
* @since 3.0.0
*/

namespace Quantum\Contracts;
namespace Quantum\Debugger\Contracts;

/**
* Interface StorageInterface
* @package Quantum\Contracts
* Interface DebuggerStoreInterface
* @package Quantum\Debugger
*/
interface StorageInterface
interface DebuggerStoreInterface
{
/**
* @param array<string> $keys
*/
public function init(array $keys): void;

/**
* Gets whole storage data
* @return mixed
Expand All @@ -42,19 +47,16 @@ public function get(string $key);
/**
* Sets storage value with the given key
* @param mixed $value
* @return void
*/
public function set(string $key, $value);
public function set(string $key, $value): void;

/**
* Deletes the data from the storage by given key
* @return void
*/
public function delete(string $key);
public function delete(string $key): void;

/**
* Deletes whole storage data
* @return void
*/
public function flush();
public function flush(): void;
}
19 changes: 15 additions & 4 deletions src/Debugger/DebuggerStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@

namespace Quantum\Debugger;

use Quantum\Contracts\StorageInterface;
use Quantum\Debugger\Contracts\DebuggerStoreInterface;

/**
* Class DebuggerStore
* @package Quantum\Debugger
*/
class DebuggerStore implements StorageInterface
class DebuggerStore implements DebuggerStoreInterface
{
/**
* @var array<string, mixed>
*/
private static array $store = [];

/**
* @param array<string> $keys
* @inheritDoc
*/
public function init(array $keys): void
{
Expand All @@ -42,19 +42,24 @@ public function init(array $keys): void
}

/**
* @inheritDoc
* @return array<string, mixed>
*/
public function all(): array
{
return self::$store;
}

/**
* @inheritDoc
*/
public function has(string $key): bool
{
return isset(self::$store[$key]);
}

/**
* @inheritDoc
* @return array<mixed>
*/
public function get(string $key): array
Expand All @@ -63,7 +68,7 @@ public function get(string $key): array
}

/**
* @param mixed $value
* @inheritDoc
*/
public function set(string $key, $value): void
{
Expand All @@ -74,13 +79,19 @@ public function set(string $key, $value): void
}
}

/**
* @inheritDoc
*/
public function delete(string $key): void
{
if ($this->has($key)) {
self::$store[$key] = [];
}
}

/**
* @inheritDoc
*/
public function flush(): void
{
self::$store = [];
Expand Down
37 changes: 34 additions & 3 deletions src/Session/Contracts/SessionStorageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,45 @@

namespace Quantum\Session\Contracts;

use Quantum\Contracts\StorageInterface;

/**
* Interface SessionStorageInterface
* @package Quantum\Session
*/
interface SessionStorageInterface extends StorageInterface
interface SessionStorageInterface
{
/**
* Gets whole storage data
* @return mixed
*/
public function all();

/**
* Checks if the storage contains a key
*/
public function has(string $key): bool;

/**
* Gets the value from the storage by given key
* @return mixed|null
*/
public function get(string $key);

/**
* Sets storage value with the given key
* @param mixed $value
*/
public function set(string $key, $value): void;

/**
* Deletes the data from the storage by given key
*/
public function delete(string $key): void;

/**
* Deletes whole storage data
*/
public function flush(): void;

/**
* Gets flash value by given key
* @return mixed|string|null
Expand Down
Loading