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

Item   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getID() 0 4 1
A getQuantity() 0 4 1
A toArray() 0 7 1
A toCommandAttribute() 0 4 1
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
     * Get Item ID
35
     * @return int
36
     */
37
    public function getID() : int
38
    {
39
        return $this->id;
40
    }
41
42
    /**
43
     * Get Item Quantity
44
     * @return int
45
     */
46
    public function getQuantity() : int
47
    {
48
        return $this->count;
49
    }
50
51
    /**
52
     * Convert Class Object To Array
53
     * @return array
54
     */
55
    public function toArray() : array
56
    {
57
        return [
58
            'id'    =>  $this->id,
59
            'count' =>  $this->count
60
        ];
61
    }
62
63
    /**
64
     * Convert Class Object To TrinityCore Command Attribute
65
     * @return string
66
     */
67
    public function toCommandAttribute() : string
68
    {
69
        return implode(':', $this->toArray());
70
    }
71
}
72