-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Represent inline config as object to hide responsibility for array-ac…
…cess to properties inside it + add access to raw data to wide compatibility (permit access to not described fields).
- Loading branch information
Showing
9 changed files
with
134 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Aeliot\TodoRegistrar\Dto\InlineConfig; | ||
|
||
use Aeliot\TodoRegistrar\InlineConfigInterface; | ||
|
||
class InlineConfig implements InlineConfigInterface | ||
{ | ||
/** | ||
* @param array<array-key,mixed> $data | ||
*/ | ||
public function __construct( | ||
private array $data, | ||
) { | ||
} | ||
|
||
/** | ||
* @param int|string $offset | ||
*/ | ||
public function offsetExists(mixed $offset): bool | ||
{ | ||
return array_key_exists($offset, $this->data); | ||
} | ||
|
||
/** | ||
* @param int|string $offset | ||
*/ | ||
public function offsetGet(mixed $offset): mixed | ||
{ | ||
return $this->data[$offset]; | ||
} | ||
|
||
/** | ||
* @param int|string $offset | ||
*/ | ||
public function offsetSet(mixed $offset, mixed $value): void | ||
{ | ||
throw new \BadMethodCallException('Setting value is not allowed.'); | ||
} | ||
|
||
/** | ||
* @param int|string $offset | ||
*/ | ||
public function offsetUnset(mixed $offset): void | ||
{ | ||
throw new \BadMethodCallException('Unsetting value is not allowed.'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Aeliot\TodoRegistrar; | ||
|
||
interface InlineConfigFactoryInterface | ||
{ | ||
/** | ||
* @param array<array-key,mixed> $input | ||
*/ | ||
public function getInlineConfig(array $input): InlineConfigInterface; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Aeliot\TodoRegistrar; | ||
|
||
interface InlineConfigInterface extends \ArrayAccess | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Aeliot\TodoRegistrar\Service\InlineConfig; | ||
|
||
use Aeliot\TodoRegistrar\Dto\InlineConfig\InlineConfig; | ||
use Aeliot\TodoRegistrar\InlineConfigFactoryInterface; | ||
use Aeliot\TodoRegistrar\InlineConfigInterface; | ||
|
||
final class InlineConfigFactory implements InlineConfigFactoryInterface | ||
{ | ||
public function getInlineConfig(array $input): InlineConfigInterface | ||
{ | ||
return new InlineConfig($input); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters