update deps & install rector

This commit is contained in:
Dominik Liebler
2019-12-14 12:50:05 +01:00
parent 04acce6759
commit 579a5ac946
87 changed files with 2432 additions and 786 deletions

View File

@@ -2,6 +2,8 @@
namespace DesignPatterns\Structural\Registry;
use InvalidArgumentException;
abstract class Registry
{
const LOGGER = 'logger';
@@ -12,19 +14,16 @@ abstract class Registry
*
* @var Service[]
*/
private static $services = [];
private static array $services = [];
/**
* @var array
*/
private static $allowedKeys = [
private static array $allowedKeys = [
self::LOGGER,
];
public static function set(string $key, Service $value)
{
if (!in_array($key, self::$allowedKeys)) {
throw new \InvalidArgumentException('Invalid key given');
throw new InvalidArgumentException('Invalid key given');
}
self::$services[$key] = $value;
@@ -33,7 +32,7 @@ abstract class Registry
public static function get(string $key): Service
{
if (!in_array($key, self::$allowedKeys) || !isset(self::$services[$key])) {
throw new \InvalidArgumentException('Invalid key given');
throw new InvalidArgumentException('Invalid key given');
}
return self::$services[$key];