FakeMockField::__construct()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 4

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 12
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
cc 4
nc 4
nop 1
crap 4
1
<?php
2
3
namespace Er1z\FakeMock\Annotations;
4
5
use Doctrine\Common\Annotations\Annotation;
6
7
/**
8
 * Class FakeAnnotation.
9
 *
10
 * @todo: make some options global for @see FakeMock propagated into here
11
 * @Annotation()
12
 */
13
class FakeMockField
14
{
15
    /**
16
     * Faker method to use.
17
     *
18
     * @var string
19
     */
20
    public $faker = null;
21
22
    /**
23
     * @var null|string
24
     */
25
    public $value = null;
26
27
    /**
28
     * Options passed to a particular callback or Faker.
29
     *
30
     * @var null|array
31
     */
32
    public $arguments = null;
33
34
    /**
35
     * Generate according to the regex.
36
     *
37
     * @var null|string
38
     */
39
    public $regex = null;
40
41
    /**
42
     * Use asserts for field type auto-detection.
43
     *
44
     * @var bool
45
     */
46
    public $useAsserts = null;
47
48
    /**
49
     * Follow asserts conditions to comply validation.
50
     *
51
     * @var bool
52
     */
53
    public $satisfyAssertsConditions = null;
54
55
    /**
56
     * Validation groups.
57
     *
58
     * @var null|string[]
59
     */
60
    public $groups = null;
61
62
    /**
63
     * Map object-type field to specified class (useful if it's an interface).
64
     *
65
     * @var string|null
66
     */
67
    public $mapToClass = null;
68
69
    /**
70
     * Map sub-objects if class type is specified.
71
     *
72
     * @var bool|null
73
     */
74
    public $recursive = null;
75
76
    /**
77
     * Locale to generate string for.
78
     *
79
     * @var null|string
80
     */
81
    public $locale = null;
82
83 340
    public function __construct($dataOrFaker = [])
84
    {
85 340
        if (is_array($dataOrFaker)) {
86 336
            foreach ($dataOrFaker as $k => $v) {
87 77
                if ('groups' == $k) {
88 16
                    $v = (array) $v;
89
                }
90
91 258
                $this->$k = $v;
92
            }
93
        } else {
94 4
            $this->faker = $dataOrFaker;
95
        }
96 340
    }
97
}
98