-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathTurnipsConfiguration.php
79 lines (67 loc) · 1.37 KB
/
TurnipsConfiguration.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
namespace DesignPatterns\Structural\DependencyInjection;
use InvalidArgumentException;
/**
* Class TurnipsConfiguration.
*/
class TurnipsConfiguration
{
/**
* @var string
*/
protected $type;
/**
* @var int
*/
protected $price;
/**
* @var int
*/
protected $count;
/**
* TurnipsConfiguration constructor.
*
* @param string $type
* @param int $price
* @param int $count
*
* @throws InvalidArgumentException
*/
public function __construct(string $type, int $price, int $count)
{
$this->type = $type;
switch ($type) {
case '健康的大頭菜':
$this->price = $price;
$this->count = $count;
break;
case '壞掉的大頭菜':
$this->price = 0;
$this->count = $count;
break;
default:
throw new InvalidArgumentException('找不到這種大頭菜分類。');
}
}
/**
* @return int
*/
public function getType(): string
{
return $this->type;
}
/**
* @return int
*/
public function getPrice(): int
{
return $this->price;
}
/**
* @return int
*/
public function getCount(): int
{
return $this->count;
}
}