Skip to content

Commit

Permalink
code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
liverbool committed Dec 26, 2017
1 parent 1e33cd7 commit 12eef9f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
14 changes: 7 additions & 7 deletions Manager/CachedManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function __construct(SettingManagerInterface $manager, CacheItemPoolInter
*
* @return string
*/
private function getCacheKey($section, $key, ?string $owner)
private function getCacheKey($section, $key, ?string $owner = null)
{
return 'phpmob-settings.' . ($owner
? sprintf('%s.%s.%s', $section, $key, $owner)
Expand All @@ -60,7 +60,7 @@ private function getCacheKey($section, $key, ?string $owner)
/**
* {@inheritdoc}
*/
public function setSetting(string $section, string $key, $value, ?string $owner, $autoFlush = false): void
public function setSetting(string $section, string $key, $value, ?string $owner = null, $autoFlush = false): void
{
$cacheKey = $this->getCacheKey($section, $key, $owner);

Expand All @@ -78,7 +78,7 @@ public function setSetting(string $section, string $key, $value, ?string $owner,
/**
* {@inheritdoc}
*/
public function getSetting(string $section, string $key, ?string $owner)
public function getSetting(string $section, string $key, ?string $owner = null)
{
$cacheKey = $this->getCacheKey($section, $key, $owner);

Expand Down Expand Up @@ -106,19 +106,19 @@ public function flush(): void
/**
* {@inheritdoc}
*/
public function get(string $path, ?string $owner)
public function get(string $path, ?string $owner = null)
{
[$section, $key] = explode('.', $path);
@list($section, $key) = explode('.', $path);

return $this->getSetting($section, $key, $owner);
}

/**
* {@inheritdoc}
*/
public function set(string $path, $value, ?string $owner): void
public function set(string $path, $value, ?string $owner = null): void
{
[$section, $key] = explode('.', $path);
@list($section, $key) = explode('.', $path);

$this->setSetting($section, $key, $value, $owner, true);
}
Expand Down
14 changes: 7 additions & 7 deletions Manager/SettingManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ private function assertSectionScope($section, ?string $owner)
/**
* {@inheritdoc}
*/
public function setSetting(string $section, string $key, $value, ?string $owner, $autoFlush = false): void
public function setSetting(string $section, string $key, $value, ?string $owner = null, $autoFlush = false): void
{
$this->assertSectionScope($section, $owner);

Expand All @@ -174,7 +174,7 @@ public function setSetting(string $section, string $key, $value, ?string $owner,
/**
* {@inheritdoc}
*/
public function getSetting(string $section, string $key, ?string $owner)
public function getSetting(string $section, string $key, ?string $owner = null)
{
$this->assertSectionScope($section, $owner);

Expand Down Expand Up @@ -205,12 +205,12 @@ public function flush(): void
/**
* {@inheritdoc}
*/
public function get(string $path, ?string $owner)
public function get(string $path, ?string $owner = null)
{
@[$section, $key] = explode('.', $path);
@list($section, $key) = explode('.', $path);

if (empty($key)) {
throw new \InvalidArgumentException("The $path should be something like: `section.key`.");
return null;
}

return $this->getSetting($section, $key, $owner);
Expand All @@ -219,9 +219,9 @@ public function get(string $path, ?string $owner)
/**
* {@inheritdoc}
*/
public function set(string $path, $value, ?string $owner): void
public function set(string $path, $value, ?string $owner = null): void
{
@[$section, $key] = explode('.', $path);
@list($section, $key) = explode('.', $path);

if (empty($key)) {
throw new \InvalidArgumentException("The $path should be something like: `section.key`.");
Expand Down
8 changes: 4 additions & 4 deletions Manager/SettingManagerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ interface SettingManagerInterface
* @param string|null $owner
* @param bool $autoFlush
*/
public function setSetting(string $section, string $key, $value, ?string $owner, $autoFlush = false): void;
public function setSetting(string $section, string $key, $value, ?string $owner = null, $autoFlush = false): void;

/**
* @param string $section
Expand All @@ -34,22 +34,22 @@ public function setSetting(string $section, string $key, $value, ?string $owner,
*
* @return mixed
*/
public function getSetting(string $section, string $key, ?string $owner);
public function getSetting(string $section, string $key, ?string $owner = null);

/**
* @param string $path
* @param string|null $owner
*
* @return mixed
*/
public function get(string $path, ?string $owner);
public function get(string $path, ?string $owner = null);

/**
* @param string $path
* @param $value
* @param string|null $owner
*/
public function set(string $path, $value, ?string $owner): void;
public function set(string $path, $value, ?string $owner = null): void;

/**
* Flush
Expand Down

0 comments on commit 12eef9f

Please sign in to comment.