Skip to content

Commit

Permalink
refactor: replace Properties::all() with Properties::jsonSerialize().
Browse files Browse the repository at this point in the history
Now `Properties` are immutable.

BREAKING CHANGE: yes
  • Loading branch information
drupol committed May 16, 2023
1 parent f72e757 commit 4fbc54b
Showing 1 changed file with 5 additions and 31 deletions.
36 changes: 5 additions & 31 deletions src/Configuration/Symfony.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@

namespace EcPhp\CasBundle\Configuration;

use EcPhp\CasLib\Configuration\Properties as PsrCasConfiguration;
use EcPhp\CasLib\Configuration\Properties as CasProperties;
use EcPhp\CasLib\Contract\Configuration\PropertiesInterface;
use ReturnTypeWillChange;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Routing\RouterInterface;
Expand All @@ -22,47 +21,22 @@

final class Symfony implements PropertiesInterface
{
private readonly PropertiesInterface $cas;
private PropertiesInterface $properties;

public function __construct(
ParameterBagInterface $parameterBag,
private readonly RouterInterface $router
) {
$this->cas = new PsrCasConfiguration(
$this->properties = new CasProperties(
$this->routeToUrl(
$parameterBag->get('cas')
)
);
}

public function all(): array
public function jsonSerialize(): array
{
return $this->cas->all();
}

#[ReturnTypeWillChange]
public function offsetExists(mixed $offset): bool
{
return $this->cas->offsetExists($offset);
}

/**
* @return array<string, mixed>|mixed
*/
#[ReturnTypeWillChange]
public function offsetGet(mixed $offset)
{
return $this->cas->offsetGet($offset);
}

public function offsetSet(mixed $offset, mixed $value): void
{
$this->cas->offsetSet($offset, $value);
}

public function offsetUnset(mixed $offset): void
{
$this->cas->offsetUnset($offset);
return $this->properties->jsonSerialize();
}

/**
Expand Down

0 comments on commit 4fbc54b

Please sign in to comment.