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

Items::__construct()   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 1
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
        $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