Completed
Push — master ( e5efba...5eb024 )
by Ivan
19:40
created

Items   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 44
rs 10
c 0
b 0
f 0
ccs 0
cts 20
cp 0
wmc 5
lcom 1
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A toArray() 0 8 2
A toCommandAttribute() 0 8 2
1
<?php namespace FreedomCore\TrinityCore\Console\Classes;
2
3
/**
4
 * Class Items
5
 * @package FreedomCore\TrinityCore\Console\Classes
6
 */
7
class Items
8
{
9
10
    /**
11
     * Array of items
12
     * @var array
13
     */
14
    protected $items = [];
15
16
    /**
17
     * Items constructor.
18
     * @param array ...$items
19
     */
20
    public function __construct(...$items)
21
    {
22
        $this->items = $items;
23
    }
24
25
    /**
26
     * Convert Class Object To Array
27
     * @return array
28
     */
29
    public function toArray() : array
30
    {
31
        $items = [];
32
        foreach ($this->items as $item) {
33
            $items[] = $item->toArray();
34
        }
35
        return $items;
36
    }
37
38
    /**
39
     * Convert Class Object To TrinityCore Command Attribute
40
     * @return string
41
     */
42
    public function toCommandAttribute() : string
43
    {
44
        $items = [];
45
        foreach ($this->items as $item) {
46
            $items[] = $item->toCommandAttribute();
47
        }
48
        return trim(implode(' ', $items));
49
    }
50
}
51