Skip to content

Commit 41e1b9a

Browse files
committed
Replace code using Value Objects
This changeset was created with a new rector ruleset (see neos/rector#11)
1 parent cc5d8fe commit 41e1b9a

File tree

51 files changed

+191
-191
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+191
-191
lines changed

Classes/Dimension/ConfigurationBasedContentDimensionSource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public function getDimension(ContentDimensionId $dimensionId): ?ContentDimension
180180
$this->initializeDimensions();
181181
}
182182

183-
return $this->contentDimensions[(string)$dimensionId] ?? null;
183+
return $this->contentDimensions[$dimensionId->value] ?? null;
184184
}
185185

186186
/**

Classes/Dimension/ContentDimension.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ public function __construct(
5656
$generalizations = [];
5757
$specializations = [];
5858
foreach ($variationEdges as $variationEdge) {
59-
$generalizations[(string)$variationEdge->specialization] = $variationEdge->generalization;
60-
$specializations[(string)$variationEdge->generalization][(string)$variationEdge->specialization]
59+
$generalizations[$variationEdge->specialization->value] = $variationEdge->generalization;
60+
$specializations[$variationEdge->generalization->value][$variationEdge->specialization->value]
6161
= $variationEdge->specialization;
6262
}
6363
$this->generalizations = $generalizations;
@@ -84,15 +84,15 @@ public function getRootValues(): array
8484

8585
public function getGeneralization(ContentDimensionValue $dimensionValue): ?ContentDimensionValue
8686
{
87-
return $this->generalizations[(string)$dimensionValue] ?? null;
87+
return $this->generalizations[$dimensionValue->value] ?? null;
8888
}
8989

9090
/**
9191
* @return array<string,ContentDimensionValue>
9292
*/
9393
public function getSpecializations(ContentDimensionValue $dimensionValue): array
9494
{
95-
return $this->specializations[(string)$dimensionValue] ?? [];
95+
return $this->specializations[$dimensionValue->value] ?? [];
9696
}
9797

9898
/**

Classes/Dimension/ContentDimensionConstraintSet.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ public function getIterator(): \ArrayIterator
6565

6666
public function getConstraints(ContentDimensionId $dimensionId): ?ContentDimensionConstraints
6767
{
68-
return $this->constraints[(string)$dimensionId] ?? null;
68+
return $this->constraints[$dimensionId->value] ?? null;
6969
}
7070

7171
public function allowsCombinationWith(
7272
ContentDimensionId $contentDimensionId,
7373
ContentDimensionValue $contentDimensionValue
7474
): bool {
75-
return isset($this->constraints[(string)$contentDimensionId])
76-
? $this->constraints[(string)$contentDimensionId]->allowsCombinationWith($contentDimensionValue)
75+
return isset($this->constraints[$contentDimensionId->value])
76+
? $this->constraints[$contentDimensionId->value]->allowsCombinationWith($contentDimensionValue)
7777
: true;
7878
}
7979
}

Classes/Dimension/ContentDimensionConstraints.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ public function __construct(
4141

4242
public function allowsCombinationWith(ContentDimensionValue $dimensionValue): bool
4343
{
44-
return $this->identifierRestrictions[(string)$dimensionValue] ?? $this->isWildcardAllowed;
44+
return $this->identifierRestrictions[$dimensionValue->value] ?? $this->isWildcardAllowed;
4545
}
4646
}

Classes/Dimension/Exception/GeneralizationIsInvalid.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ public static function becauseComparedValueIsNoSpecialization(
2929
ContentDimensionId $dimensionId
3030
): self {
3131
return new self(
32-
'"' . $comparedValue . '" is no specialization of "' . $value
33-
. '" in dimension "' . $dimensionId . '".'
32+
'"' . $comparedValue->value . '" is no specialization of "' . $value->value
33+
. '" in dimension "' . $dimensionId->value . '".'
3434
);
3535
}
3636
}

Classes/DimensionSpace/AbstractDimensionSpacePoint.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,28 +89,28 @@ final public function isDirectVariantInDimension(
8989
return false;
9090
}
9191
if (
92-
$this->coordinates[(string)$contentDimensionId]
93-
=== $other->coordinates[(string)$contentDimensionId]
92+
$this->coordinates[$contentDimensionId->value]
93+
=== $other->coordinates[$contentDimensionId->value]
9494
) {
9595
return false;
9696
}
9797

9898
$theseCoordinates = $this->coordinates;
9999
$otherCoordinates = $other->coordinates;
100-
unset($theseCoordinates[(string)$contentDimensionId]);
101-
unset($otherCoordinates[(string)$contentDimensionId]);
100+
unset($theseCoordinates[$contentDimensionId->value]);
101+
unset($otherCoordinates[$contentDimensionId->value]);
102102

103103
return $theseCoordinates === $otherCoordinates;
104104
}
105105

106106
final public function hasCoordinate(Dimension\ContentDimensionId $dimensionId): bool
107107
{
108-
return isset($this->coordinates[(string)$dimensionId]);
108+
return isset($this->coordinates[$dimensionId->value]);
109109
}
110110

111111
final public function getCoordinate(Dimension\ContentDimensionId $dimensionId): ?string
112112
{
113-
return $this->coordinates[(string)$dimensionId] ?? null;
113+
return $this->coordinates[$dimensionId->value] ?? null;
114114
}
115115

116116
/**

Classes/DimensionSpace/ContentDimensionZookeeper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ protected function initializeAllowedCombinations(): void
4444
assert($contentDimension instanceof Dimension\ContentDimension);
4545
if ($dimensionCombinations === []) {
4646
foreach ($contentDimension->values as $serializedValue => $dimensionValue) {
47-
$dimensionCombinations[] = [(string)$contentDimension->id => $dimensionValue];
47+
$dimensionCombinations[] = [$contentDimension->id->value => $dimensionValue];
4848
}
4949
} else {
5050
$this->extendCombinationsWithDimension($dimensionCombinations, $contentDimension);
@@ -82,7 +82,7 @@ protected function extendCombinationsWithDimension(
8282
}
8383
}
8484
$newDimensionCombination = $dimensionCombination;
85-
$newDimensionCombination[(string)$contentDimension->id] = $currentDimensionValue;
85+
$newDimensionCombination[$contentDimension->id->value] = $currentDimensionValue;
8686
$currentDimensionCombinations[] = $newDimensionCombination;
8787
}
8888
}
@@ -111,7 +111,7 @@ public function getAllowedDimensionSubspace(): DimensionSpacePointSet
111111
foreach ($this->getAllowedCombinations() as $dimensionCombination) {
112112
$coordinates = [];
113113
foreach ($dimensionCombination as $contentDimensionId => $contentDimensionValue) {
114-
$coordinates[$contentDimensionId] = (string)$contentDimensionValue;
114+
$coordinates[$contentDimensionId] = $contentDimensionValue->value;
115115
}
116116

117117
$point = DimensionSpacePoint::fromArray($coordinates);

Classes/DimensionSpace/ContentSubgraphVariationWeight.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function __construct(
5454
public function getWeightInDimension(
5555
Dimension\ContentDimensionId $dimensionId
5656
): ?Dimension\ContentDimensionValueSpecializationDepth {
57-
return $this->weight[(string)$dimensionId] ?? null;
57+
return $this->weight[$dimensionId->value] ?? null;
5858
}
5959

6060
public function canBeComparedTo(ContentSubgraphVariationWeight $other): bool

Classes/DimensionSpace/DimensionSpacePoint.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ final public static function fromUriRepresentation(string $encoded): self
9090
final public function vary(Dimension\ContentDimensionId $dimensionId, string $value): self
9191
{
9292
$variedCoordinates = $this->coordinates;
93-
$variedCoordinates[(string)$dimensionId] = $value;
93+
$variedCoordinates[$dimensionId->value] = $value;
9494

9595
return self::instance($variedCoordinates);
9696
}

Classes/DimensionSpace/InterDimensionalVariationGraph.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ protected function determineWeightNormalizationBase(): int
139139
if (is_null($this->weightNormalizationBase)) {
140140
$base = 0;
141141
foreach ($this->contentDimensionSource->getContentDimensionsOrderedByPriority() as $contentDimension) {
142-
$base = max($base, $contentDimension->getMaximumDepth()->depth + 1);
142+
$base = max($base, $contentDimension->getMaximumDepth()->value + 1);
143143
}
144144

145145
$this->weightNormalizationBase = $base;
@@ -169,7 +169,7 @@ protected function initializeVariations(): void
169169
$dimension = $this->contentDimensionSource->getDimension($dimensionId);
170170
foreach ($dimension->getSpecializations($contentDimensionValue) as $specializedValue) {
171171
$specializedDimensionSpacePoint = $generalization->dimensionSpacePoint
172-
->vary($dimensionId, (string)$specializedValue);
172+
->vary($dimensionId, $specializedValue->value);
173173
if (
174174
!$this->contentDimensionZookeeper->getAllowedDimensionSubspace()
175175
->contains($specializedDimensionSpacePoint)

0 commit comments

Comments
 (0)