Completed
Pull Request — master (#20)
by Anatoliy
18:45 queued 08:46
created

ArrayTypeMock   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
c 0
b 0
f 0
dl 0
loc 48
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSample() 0 18 3
A getOptimalCount() 0 18 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::get($type_enum) as $type_gen_list) {
40
            foreach ($type_gen_list as $type_mock) {
41
                yield [$type_mock];
42
            }
43
        }
44
    }
45
46
    /**
47
     * @return int
48
     */
49
    protected static function getOptimalCount()
50
    {
51
        static $count = null;
52
        if (is_null($count)) {
53
            $type_enum = [
54
                TypeEnum::STRING
55
                , TypeEnum::BOOLEAN
56
                , TypeEnum::DOUBLE
57
                , TypeEnum::INTEGER
58
                , TypeEnum::NULL
59
                , TypeEnum::OBJECT
60
                , TypeEnum::RESOURCE
61
                , TypeEnum::UNKNOWN
62
            ];
63
            $count = count(TypeList::get($type_enum));
64
        }
65
66
        return $count;
67
    }
68
}