HasDetail   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A detail() 0 9 3
A getDetail() 0 3 1
A getDetails() 0 3 1
1
<?php
2
3
namespace Shetabit\Multipay\Traits;
4
5
trait HasDetail
6
{
7
    /**
8
     * details
9
     *
10
     * @var array
11
     */
12
    protected $details = [];
13
14
    /**
15
     * Set a piece of data to the details.
16
     *
17
     * @param $key
18
     * @param $value|null
19
     *
20
     * @return $this
21
     */
22
    public function detail($key, $value = null)
23
    {
24
        $key = is_array($key) ? $key : [$key => $value];
25
26
        foreach ($key as $k => $v) {
27
            $this->details[$k] = $v;
28
        }
29
30
        return $this;
31
    }
32
33
    /**
34
     * Retrieve detail using its name
35
     *
36
     * @param $name
37
     * @return string|null
38
     */
39
    public function getDetail($name)
40
    {
41
        return $this->details[$name] ?? null;
42
    }
43
44
    /**
45
     * Get the value of details
46
     */
47
    public function getDetails() : array
48
    {
49
        return $this->details;
50
    }
51
}
52