AbstractData::getName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
/**
3
 * @author Serhii Nekhaienko <[email protected]>
4
 * @license GPL
5
 * @copyright Serhii Nekhaienko &copy 2018
6
 * @version 4.0.0
7
 * @project endorphin-studio/browser-detector
8
 */
9
10
namespace EndorphinStudio\Detector\Data;
11
12
/**
13
 * Class AbstractData Abstract data with result detector
14
 * @package EndorphinStudio\Detector\Data
15
 */
16
abstract class AbstractData implements \JsonSerializable
17
{
18
    /**
19
     * @var Result Link to Result object
20
     */
21
    protected $result;
22
23
    /**
24
     * @var string Name
25
     */
26
    protected $name;
27
28
    /**
29
     * Set name of object
30
     * @param string $name Name
31
     */
32
    public function setName(string $name)
33
    {
34
        $this->name = $name;
35
    }
36
37
    /**
38
     * Set object type
39
     * @param string $type Type
40
     */
41
    public function setType(string $type)
42
    {
43
        $this->type = $type;
44
    }
45
46
    /**
47
     * @var string Type
48
     */
49
    protected $type;
50
51
    /**
52
     * Get object name
53
     * @return string
54
     */
55
    public function getName(): string
56
    {
57
        return $this->name ?? 'not available';
58
    }
59
60
    /**
61
     * Get object type
62
     * @return string
63
     */
64
    public function getType(): string
65
    {
66
        return $this->type ?? 'not available';
67
    }
68
69
    /**
70
     * AbstractData constructor.
71
     * @param Result $result
72
     */
73
    public function __construct(Result $result)
74
    {
75
        $this->result = $result;
76
    }
77
78
    public function jsonSerialize()
79
    {
80
        $fields = get_object_vars($this);
81
        unset($fields['result']);
82
        return $fields;
83
    }
84
}