|
| 1 | +<?php declare(strict_types = 1); |
| 2 | + |
| 3 | +namespace Tests\Mocks; |
| 4 | + |
| 5 | +use EmptyIterator; |
| 6 | +use Iterator; |
| 7 | +use Nextras\Orm\Collection\ICollection; |
| 8 | +use Nextras\Orm\Collection\MemoryCollection; |
| 9 | +use Nextras\Orm\Entity\IEntity; |
| 10 | +use Nextras\Orm\Mapper\IRelationshipMapper; |
| 11 | +use RuntimeException; |
| 12 | + |
| 13 | +/** |
| 14 | + * @implements ICollection<IEntity> |
| 15 | + */ |
| 16 | +final class StubCollection implements ICollection |
| 17 | +{ |
| 18 | + |
| 19 | + /** |
| 20 | + * @param array<string, mixed>|array<mixed> $conds |
| 21 | + */ |
| 22 | + public function getBy(array $conds): ?IEntity |
| 23 | + { |
| 24 | + return null; |
| 25 | + } |
| 26 | + |
| 27 | + /** |
| 28 | + * @param array<string, mixed>|array<mixed> $conds |
| 29 | + */ |
| 30 | + public function getByChecked(array $conds): IEntity |
| 31 | + { |
| 32 | + throw new RuntimeException(); |
| 33 | + } |
| 34 | + |
| 35 | + public function getById(mixed $id): ?IEntity |
| 36 | + { |
| 37 | + return null; |
| 38 | + } |
| 39 | + |
| 40 | + public function getByIdChecked(mixed $id): IEntity |
| 41 | + { |
| 42 | + throw new RuntimeException(); |
| 43 | + } |
| 44 | + |
| 45 | + /** |
| 46 | + * @param array<mixed> $conds |
| 47 | + */ |
| 48 | + public function findBy(array $conds): ICollection |
| 49 | + { |
| 50 | + return $this; |
| 51 | + } |
| 52 | + |
| 53 | + /** |
| 54 | + * @param string|array<string, string>|list<mixed> $expression |
| 55 | + * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint |
| 56 | + */ |
| 57 | + public function orderBy($expression, string $direction = self::ASC): ICollection |
| 58 | + { |
| 59 | + return $this; |
| 60 | + } |
| 61 | + |
| 62 | + public function resetOrderBy(): ICollection |
| 63 | + { |
| 64 | + return $this; |
| 65 | + } |
| 66 | + |
| 67 | + public function limitBy(int $limit, int|null $offset = null): ICollection |
| 68 | + { |
| 69 | + return $this; |
| 70 | + } |
| 71 | + |
| 72 | + public function fetch(): ?IEntity |
| 73 | + { |
| 74 | + return null; |
| 75 | + } |
| 76 | + |
| 77 | + public function fetchChecked(): IEntity |
| 78 | + { |
| 79 | + throw new RuntimeException(); |
| 80 | + } |
| 81 | + |
| 82 | + /** |
| 83 | + * @return list<IEntity> |
| 84 | + */ |
| 85 | + public function fetchAll(): array |
| 86 | + { |
| 87 | + return []; |
| 88 | + } |
| 89 | + |
| 90 | + /** |
| 91 | + * @return array<int|string, mixed> |
| 92 | + */ |
| 93 | + public function fetchPairs(string|null $key = null, string|null $value = null): array |
| 94 | + { |
| 95 | + return []; |
| 96 | + } |
| 97 | + |
| 98 | + /** |
| 99 | + * @return Iterator<int, IEntity> |
| 100 | + */ |
| 101 | + public function getIterator(): Iterator |
| 102 | + { |
| 103 | + return new EmptyIterator(); |
| 104 | + } |
| 105 | + |
| 106 | + public function count(): int |
| 107 | + { |
| 108 | + return 0; |
| 109 | + } |
| 110 | + |
| 111 | + public function countStored(): int |
| 112 | + { |
| 113 | + return 0; |
| 114 | + } |
| 115 | + |
| 116 | + public function toMemoryCollection(): MemoryCollection |
| 117 | + { |
| 118 | + throw new RuntimeException(); |
| 119 | + } |
| 120 | + |
| 121 | + public function setRelationshipMapper(IRelationshipMapper|null $mapper): ICollection |
| 122 | + { |
| 123 | + return $this; |
| 124 | + } |
| 125 | + |
| 126 | + public function getRelationshipMapper(): ?IRelationshipMapper |
| 127 | + { |
| 128 | + return null; |
| 129 | + } |
| 130 | + |
| 131 | + public function setRelationshipParent(IEntity $parent): ICollection |
| 132 | + { |
| 133 | + return $this; |
| 134 | + } |
| 135 | + |
| 136 | + public function subscribeOnEntityFetch(callable $callback): void |
| 137 | + { |
| 138 | + // stub, intentionally empty |
| 139 | + } |
| 140 | + |
| 141 | +} |
0 commit comments