Skip to content

Commit

Permalink
Add SettingsInterface for DI container
Browse files Browse the repository at this point in the history
  • Loading branch information
lav45 committed Nov 23, 2024
1 parent 600a053 commit a4561ce
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* @mixin CacheBehavior
* @mixin QuickAccessBehavior
*/
class Settings extends Component implements \ArrayAccess
class Settings extends Component implements SettingsInterface
{
public const EVENT_BEFORE_GET = 'beforeGetValue';
public const EVENT_AFTER_GET = 'afterGetValue';
Expand Down Expand Up @@ -82,7 +82,7 @@ public function buildKey($key)
* @param mixed $value
* @return string
*/
public function encode($value)
protected function encode($value)
{
if ($this->serializer === null) {
return serialize($value);
Expand All @@ -97,7 +97,7 @@ public function encode($value)
* @param string $value
* @return mixed
*/
public function decode($value)
protected function decode($value)
{
if ($this->serializer === null) {
return @unserialize($value, ['allowed_classes' => true]);
Expand Down
26 changes: 26 additions & 0 deletions src/SettingsInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php declare(strict_types=1);

namespace lav45\settings;

interface SettingsInterface extends \ArrayAccess
{
/**
* @param string|array $key
* @param null $default
* @return mixed
*/
public function get($key, $default = null);

/**
* @param string|array $key
* @param mixed $value
* @return boolean
*/
public function set($key, $value);

/**
* @param string $key
* @return boolean
*/
public function delete($key);
}

0 comments on commit a4561ce

Please sign in to comment.