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

Items::toCommandAttribute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 0
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
ccs 0
cts 8
cp 0
crap 6
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