| Total Complexity | 9 |
| Total Lines | 55 |
| Duplicated Lines | 0 % |
| Coverage | 92.86% |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | class DeserializationContext extends Context |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | 5 | * @var int |
|
| 14 | */ |
||
| 15 | 5 | private $depth = 0; |
|
| 16 | |||
| 17 | /** |
||
| 18 | 1 | * @var array<string, PersistentCollection> |
|
| 19 | */ |
||
| 20 | 1 | private $persistentCollections = []; |
|
| 21 | |||
| 22 | public static function create(): self |
||
| 23 | 6 | { |
|
| 24 | return new self(); |
||
| 25 | 6 | } |
|
| 26 | |||
| 27 | public function getDirection(): int |
||
| 28 | 80 | { |
|
| 29 | return GraphNavigatorInterface::DIRECTION_DESERIALIZATION; |
||
| 30 | 80 | } |
|
| 31 | 80 | ||
| 32 | public function getDepth(): int |
||
| 33 | 77 | { |
|
| 34 | return $this->depth; |
||
| 35 | 77 | } |
|
| 36 | |||
| 37 | public function increaseDepth(): void |
||
| 38 | { |
||
| 39 | 77 | $this->depth += 1; |
|
| 40 | 77 | } |
|
| 41 | |||
| 42 | public function decreaseDepth(): void |
||
| 43 | { |
||
| 44 | if ($this->depth <= 0) { |
||
| 45 | throw new LogicException('Depth cannot be smaller than zero.'); |
||
| 46 | } |
||
| 47 | |||
| 48 | $this->depth -= 1; |
||
| 49 | } |
||
| 50 | |||
| 51 | public function addPersistentCollection(PersistentCollection $collection, array $path): void |
||
| 52 | { |
||
| 53 | $this->persistentCollections[implode('.', $path)] = $collection; |
||
| 54 | } |
||
| 55 | |||
| 56 | public function removePersistentCollectionForCurrentPath(): ?PersistentCollection |
||
| 65 | } |
||
| 66 | } |
||
| 67 |