Passed
Push — master ( 199c1a...b4b355 )
by Бабичев
01:42
created

PregObject::__isset()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Bavix\Helpers\Results;
4
5
use Bavix\Helpers\Arr;
6
7
/**
8
 * Class PregObject
9
 *
10
 * @package Bavix\Helpers\Results
11
 *
12
 * @property array $matches
13
 * @property int   $flags
14
 * @property int   $offset
15
 * @property int   $result
16
 */
17
class PregObject
18
{
19
20
    /**
21
     * @var array
22
     */
23
    protected $data = [];
24
25
    /**
26
     * PregObject constructor.
27
     *
28
     * @param int $flags
29
     * @param int $offset
30
     */
31 2
    public function __construct($flags = 0, $offset = 0)
32
    {
33 2
        $this->flags  = $flags;
34 2
        $this->offset = $offset;
35 2
    }
36
37
    /**
38
     * @param string $name
39
     *
40
     * @return mixed
41
     */
42 2
    public function &__get($name)
43
    {
44 2
        if (!Arr::keyExists($this->data, $name))
45
        {
46 2
            $this->data[$name] = null;
47
        }
48
49 2
        return $this->data[$name];
50
    }
51
52
    /**
53
     * @param string $name
54
     * @param mixed  $value
55
     */
56 2
    public function __set($name, $value)
57
    {
58 2
        $this->data[$name] = $value;
59 2
    }
60
61
    /**
62
     * @param string $name
63
     *
64
     * @return bool
65
     */
66 2
    public function __isset($name)
67
    {
68 2
        return isset($this->data[$name]);
69
    }
70
71
}
72