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

Item::toCommandAttribute()   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 Item
5
 * @package FreedomCore\TrinityCore\Console\Classes
6
 */
7
class Item
8
{
9
10
    /**
11
     * Item ID
12
     * @var int|null
13
     */
14
    protected $id = null;
15
16
    /**
17
     * Item Count
18
     * @var int|null
19
     */
20
    protected $count = null;
21
22
    /**
23
     * Item constructor.
24
     * @param int $itemID
25
     * @param int $itemCount
26
     */
27
    public function __construct(int $itemID, int $itemCount = 1)
28
    {
29
        $this->id = $itemID;
30
        $this->count = $itemCount;
31
    }
32
33
    /**
34
     * Convert Class Object To Array
35
     * @return array
36
     */
37
    public function toArray() : array
38
    {
39
        return [
40
            $this->id,
41
            $this->count
42
        ];
43
    }
44
45
    /**
46
     * Convert Class Object To TrinityCore Command Attribute
47
     * @return string
48
     */
49
    public function toCommandAttribute() : string
50
    {
51
        return implode(':', $this->toArray());
52
    }
53
}
54