ArrayTypeMock   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 28
dl 0
loc 50
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSample() 0 19 3
A getOptimalCount() 0 19 2
1
<?php
2
declare(strict_types=1);
3
/**
4
 * Created by PhpStorm.
5
 * User: danchukas
6
 * Date: 2017-07-18 08:46
7
 */
8
9
namespace DanchukAS\Mock\Type;
10
11
use DanchukAS\Mock\TypeEnum;
12
use DanchukAS\Mock\TypeList;
13
use DanchukAS\Mock\TypeMock;
14
15
/**
16
 * Class NullTypeMock
17
 * @package DanchukAS\Mock\Type
18
 */
19
class ArrayTypeMock extends TypeMock
20
{
21
    /**
22
     * @return \Generator
23
     */
24
    public static function getSample()
25
    {
26
        yield ['empty' => []];
27
28
        $type_enum = [
29
            TypeEnum::STRING
30
            , TypeEnum::BOOLEAN
31
            , TypeEnum::DOUBLE
32
            , TypeEnum::INTEGER
33
            , TypeEnum::NULL
34
            , TypeEnum::OBJECT
35
            , TypeEnum::RESOURCE
36
            , TypeEnum::UNKNOWN
37
        ];
38
39
        foreach (TypeList::getMockList($type_enum) as $type_gen_list) {
40
            /** @noinspection ForeachSourceInspection */
41
            foreach ($type_gen_list as $type_mock) {
42
                yield [$type_mock];
43
            }
44
        }
45
    }
46
47
    /**
48
     * @return int
49
     */
50
    protected static function getOptimalCount()
51
    {
52
        static $count = null;
53
        if (null === $count) {
54
            $type_enum = [
55
                TypeEnum::STRING
56
                , TypeEnum::BOOLEAN
57
                , TypeEnum::DOUBLE
58
                , TypeEnum::INTEGER
59
                , TypeEnum::NULL
60
                , TypeEnum::OBJECT
61
                , TypeEnum::RESOURCE
62
                , TypeEnum::UNKNOWN
63
            ];
64
            $count = count(TypeList::getMockList($type_enum));
65
            self::$optimalCount = $count;
66
        }
67
68
        return parent::getOptimalCount();
69
    }
70
}