Skip to content

Commit de0342b

Browse files
committed
cleanup
1 parent c9b555f commit de0342b

15 files changed

Lines changed: 33 additions & 50 deletions

src/Attribute/RouteParamValue/AbstractValues.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@
66

77
abstract class AbstractValues implements ValuesInterface
88
{
9+
/**
10+
* @return non-empty-list<?scalar>
11+
*/
12+
abstract protected function getValues(): array;
13+
914
/**
1015
* {@inheritDoc}
1116
*/
12-
public function toArray(): array
17+
final public function toArray(): array
1318
{
1419
return [
1520
'type' => static::type(),

src/Attribute/RouteParamValue/CompoundValues.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66

77
use Sofascore\PurgatoryBundle\Attribute\PurgeOn;
88
use Sofascore\PurgatoryBundle\Exception\InvalidArgumentException;
9+
use Sofascore\PurgatoryBundle\Exception\RuntimeException;
910

10-
final class CompoundValues extends AbstractValues
11+
final class CompoundValues implements ValuesInterface
1112
{
1213
/**
1314
* @var non-empty-list<ValuesInterface>
1415
*/
15-
private readonly array $values;
16+
public readonly array $values;
1617

1718
/**
1819
* @param string|non-empty-list<string>|ValuesInterface $value
@@ -38,14 +39,6 @@ public function __construct(
3839
$this->values = $normalized;
3940
}
4041

41-
/**
42-
* @return list<ValuesInterface>
43-
*/
44-
public function getValues(): array
45-
{
46-
return $this->values;
47-
}
48-
4942
/**
5043
* {@inheritDoc}
5144
*/

src/Attribute/RouteParamValue/DynamicValues.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ final class DynamicValues extends AbstractValues
1010
* @param string $alias Alias defined in {@see AsRouteParamService} attribute
1111
*/
1212
public function __construct(
13-
private readonly string $alias,
14-
private readonly ?string $arg = null,
13+
public readonly string $alias,
14+
public readonly ?string $arg = null,
1515
) {
1616
}
1717

1818
/**
19-
* @return list<?string>
19+
* @return non-empty-list<?string>
2020
*/
21-
public function getValues(): array
21+
protected function getValues(): array
2222
{
2323
return [$this->alias, $this->arg];
2424
}

src/Attribute/RouteParamValue/EnumValues.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ final class EnumValues extends AbstractValues
1212
* @param class-string<\BackedEnum> $enum
1313
*/
1414
public function __construct(
15-
private readonly string $enum,
15+
public readonly string $enum,
1616
) {
1717
if (!is_a($this->enum, \BackedEnum::class, true)) {
1818
throw new InvalidArgumentException('The argument must be a backed enum.');
1919
}
2020
}
2121

2222
/**
23-
* @return list<class-string<\BackedEnum>>
23+
* @return non-empty-list<class-string<\BackedEnum>>
2424
*/
25-
public function getValues(): array
25+
protected function getValues(): array
2626
{
2727
return [$this->enum];
2828
}

src/Attribute/RouteParamValue/ExpressionValues.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
final class ExpressionValues extends AbstractValues
1111
{
12-
private readonly Expression $expression;
12+
public readonly Expression $expression;
1313

1414
public function __construct(
1515
string|Expression $expression,
@@ -18,19 +18,11 @@ public function __construct(
1818
}
1919

2020
/**
21-
* @return list<Expression>
21+
* @return non-empty-list<string>
2222
*/
23-
public function getValues(): array
23+
protected function getValues(): array
2424
{
25-
return [$this->expression];
26-
}
27-
28-
public function toArray(): array
29-
{
30-
return [
31-
'type' => self::type(),
32-
'values' => [(string) $this->expression],
33-
];
25+
return [(string) $this->expression];
3426
}
3527

3628
public static function type(): string

src/Attribute/RouteParamValue/PropertyValues.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
final class PropertyValues extends AbstractValues
88
{
99
/** @var non-empty-list<string> */
10-
private readonly array $properties;
10+
public readonly array $properties;
1111

1212
public function __construct(
1313
string $property,
@@ -19,7 +19,7 @@ public function __construct(
1919
/**
2020
* @return non-empty-list<string>
2121
*/
22-
public function getValues(): array
22+
protected function getValues(): array
2323
{
2424
return $this->properties;
2525
}

src/Attribute/RouteParamValue/RawValues.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
final class RawValues extends AbstractValues
88
{
99
/** @var non-empty-list<?scalar> */
10-
private readonly array $values;
10+
public readonly array $values;
1111

1212
public function __construct(
1313
int|float|string|bool|null $value,
@@ -19,7 +19,7 @@ public function __construct(
1919
/**
2020
* @return non-empty-list<?scalar>
2121
*/
22-
public function getValues(): array
22+
protected function getValues(): array
2323
{
2424
return $this->values;
2525
}

src/Attribute/RouteParamValue/ValuesInterface.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@
66

77
interface ValuesInterface
88
{
9-
/**
10-
* @return list<mixed>
11-
*/
12-
public function getValues(): array;
13-
149
/**
1510
* @return array{type: string, values: list<mixed>}
1611
*/

src/Cache/PropertyResolver/InverseValuesBuilder/CompoundInverseValuesBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function build(ValuesInterface $values, string $associationClass, string
3030
fn (ValuesInterface $values): ValuesInterface => $this->getInverseValuesBuilderFor($values)
3131
?->build($values, $associationClass, $associationTarget)
3232
?? $values,
33-
$values->getValues(),
33+
$values->values,
3434
),
3535
);
3636
}

src/Cache/PropertyResolver/InverseValuesBuilder/DynamicInverseValuesBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ public static function for(): string
1919

2020
public function build(ValuesInterface $values, string $associationClass, string $associationTarget): ValuesInterface
2121
{
22-
/** @var string $alias */
23-
[$alias, $arg] = $values->getValues();
22+
$alias = $values->alias;
23+
$arg = $values->arg;
2424

2525
return new DynamicValues(
2626
alias: $alias,

0 commit comments

Comments
 (0)