Options   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
eloc 5
c 1
b 0
f 1
dl 0
loc 25
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setOptions() 0 4 1
A option() 0 3 1
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