DataSet::setProperties()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 2
eloc 5
nc 2
nop 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Crossjoin\Browscap\Source;
5
6
/**
7
 * Class DataSet
8
 *
9
 * @package Crossjoin\Browscap\Source
10
 * @author Christoph Ziegenberg <[email protected]>
11
 * @link https://github.com/crossjoin/browscap
12
 */
13
class DataSet
14
{
15
    /**
16
     * @var string
17
     */
18
    protected $pattern;
19
20
    /**
21
     * @var array
22
     */
23
    protected $properties = [];
24
25
    /**
26
     * DataSet constructor.
27
     *
28
     * @param string $pattern
29
     */
30
    public function __construct(string $pattern)
31
    {
32
        $this->setPattern($pattern);
33
    }
34
35
    /**
36
     * @return string
37
     */
38
    public function getPattern() : string
39
    {
40
        return $this->pattern;
41
    }
42
43
    /**
44
     * @param string $pattern
45
     */
46
    protected function setPattern(string $pattern)
47
    {
48
        $this->pattern = $pattern;
49
    }
50
51
    /**
52
     * @return array
53
     */
54
    public function getProperties() : array
55
    {
56
        return $this->properties;
57
    }
58
59
    /**
60
     * @param array $properties
61
     *
62
     * @return DataSet
63
     */
64
    public function setProperties(array $properties) : DataSet
65
    {
66
        $this->properties = [];
67
68
        foreach ($properties as $key => $value) {
69
            $this->addProperty($key, $value);
70
        }
71
72
        return $this;
73
    }
74
75
    /**
76
     * @param string $key
77
     * @param string $value
78
     *
79
     * @return DataSet
80
     */
81
    public function addProperty(string $key, string $value) : DataSet
82
    {
83
        $this->properties[$key] = $value;
84
85
        return $this;
86
    }
87
}
88