Options::option()   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 1
Metric Value
eloc 1
c 1
b 0
f 1
dl 0
loc 3
rs 10
cc 1
nc 1
nop 2
1
<?php
2
/**
3
 * Extension options
4
 * User: moyo
5
 * Date: 2018/7/31
6
 * Time: 10:23 PM
7
 */
8
9
namespace Carno\Net\Chips\Endpoint;
10
11
trait Options
12
{
13
    /**
14
     * @var array
15
     */
16
    private $options = [];
17
18
    /**
19
     * @param string $key
20
     * @param mixed $default
21
     * @return mixed
22
     */
23
    public function option(string $key, $default = null)
24
    {
25
        return $this->options[$key] ?? $default;
26
    }
27
28
    /**
29
     * @param array $override
30
     * @return static
31
     */
32
    public function setOptions(array $override) : self
33
    {
34
        $this->options = array_merge($this->options, $override);
35
        return $this;
36
    }
37
}
38