Completed
Push — master ( 5eb024...21170c )
by Ivan
04:45
created

Items::getItems()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 0
cts 4
cp 0
crap 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
        if (isset($items[0][0])) {
23
            $items = $items[0];
24
        }
25
        $this->items = $items;
26
    }
27
28
    /**
29
     * Get Items
30
     * @return array
31
     */
32
    public function getItems() : array
33
    {
34
        return $this->items;
35
    }
36
37
    /**
38
     * Count how many items we are created
39
     * @return int
40
     */
41
    public function count() : int
42
    {
43
        return count($this->items);
44
    }
45
46
    /**
47
     * Convert Class Object To Array
48
     * @return array
49
     */
50
    public function toArray() : array
51
    {
52
        $items = [];
53
        foreach ($this->items as $item) {
54
            /**
55
             * @var $item Item
56
             */
57
            $items[] = $item->toArray();
58
        }
59
        return $items;
60
    }
61
62
    /**
63
     * Convert Class Object To TrinityCore Command Attribute
64
     * @return string
65
     */
66
    public function toCommandAttribute() : string
67
    {
68
        $items = [];
69
        foreach ($this->items as $item) {
70
            $items[] = $item->toCommandAttribute();
71
        }
72
        return trim(implode(' ', $items));
73
    }
74
}
75