Passed
Push — master ( 4f415b...b6b0b7 )
by Gabriel
03:01
created

HasDataTrait::initData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
ccs 2
cts 2
cp 1
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Nip\Controllers\Response\ResponsePayload;
4
5
use Nip\Controllers\Response\ResponseData;
6
7
/**
8
 * Trait HasDataTrait
9
 * @package Nip\Controllers\Response\ResponsePayload
10
 */
11
trait HasDataTrait
12
{
13
    /**
14
     * @var ResponseData
15
     */
16
    public $data;
17
18 4
    protected function initData()
19
    {
20 4
        $this->data = new ResponseData();
21 4
    }
22
23
    /**
24
     * @param string $key
25
     * @return mixed|null
26
     */
27
    public function __get(string $key)
28
    {
29
        return $this->data->get($key);
30
    }
31
32
    /**
33
     * @param $name
34
     * @param $value
35
     */
36
    public function __set($name, $value)
37
    {
38
        $this->data->set($name, $value);
39
    }
40
41
    /**
42
     * @return mixed
43
     */
44
    public function all()
45
    {
46
        return $this->data->all();
47
    }
48
}