| Total Complexity | 5 |
| Total Lines | 40 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | abstract class TypeMock |
||
| 16 | { |
||
| 17 | |||
| 18 | protected static $optimalCount = 1; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @param int $count Кількість елементів для генератора |
||
| 22 | * @return \array |
||
| 23 | */ |
||
| 24 | public static function getGenerator($count = null) |
||
| 25 | { |
||
| 26 | if (null === $count) { |
||
| 27 | $count = static::getOptimalCount(); |
||
| 28 | } |
||
| 29 | |||
| 30 | $mock_list = []; |
||
| 31 | |||
| 32 | $generator = static::getSample(); |
||
| 33 | foreach ($generator as $value) { |
||
| 34 | $mock_list[] = $value; |
||
| 35 | if (--$count <= 0) { |
||
| 36 | break; |
||
| 37 | } |
||
| 38 | } |
||
| 39 | |||
| 40 | return $mock_list; |
||
|
|
|||
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * @return int |
||
| 45 | */ |
||
| 46 | protected static function getOptimalCount() |
||
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * @return \Generator sample of type |
||
| 53 | */ |
||
| 54 | abstract public static function getSample(); |
||
| 55 | } |