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

HasDataTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 30%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 6
dl 0
loc 36
rs 10
c 1
b 0
f 0
ccs 3
cts 10
cp 0.3

4 Methods

Rating   Name   Duplication   Size   Complexity  
A initData() 0 3 1
A __set() 0 3 1
A all() 0 3 1
A __get() 0 3 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
}