@@ 10-57 (lines=48) @@ | ||
7 | * Class BrickHouse |
|
8 | * @package codenixsv\Patterns\Creational\FactoryMethod |
|
9 | */ |
|
10 | class BrickHouse implements HouseInterface |
|
11 | { |
|
12 | /** |
|
13 | * @var int |
|
14 | */ |
|
15 | private $width; |
|
16 | ||
17 | /** |
|
18 | * @var int |
|
19 | */ |
|
20 | private $height; |
|
21 | ||
22 | /** |
|
23 | * @var string |
|
24 | */ |
|
25 | private $material; |
|
26 | ||
27 | public function __construct(int $width, int $height) |
|
28 | { |
|
29 | $this->height = $height; |
|
30 | $this->width = $width; |
|
31 | $this->material = 'bricks'; |
|
32 | } |
|
33 | ||
34 | /** |
|
35 | * @return int |
|
36 | */ |
|
37 | public function getHeight(): int |
|
38 | { |
|
39 | return $this->height; |
|
40 | } |
|
41 | ||
42 | /** |
|
43 | * @return int |
|
44 | */ |
|
45 | public function getWidth(): int |
|
46 | { |
|
47 | return $this->width; |
|
48 | } |
|
49 | ||
50 | /** |
|
51 | * @return string |
|
52 | */ |
|
53 | public function getMaterial(): string |
|
54 | { |
|
55 | return $this->material; |
|
56 | } |
|
57 | } |
|
58 |
@@ 10-57 (lines=48) @@ | ||
7 | * Class StickHouse |
|
8 | * @package codenixsv\Patterns\Creational\FactoryMethod |
|
9 | */ |
|
10 | class StickHouse implements HouseInterface |
|
11 | { |
|
12 | /** |
|
13 | * @var int |
|
14 | */ |
|
15 | private $width; |
|
16 | ||
17 | /** |
|
18 | * @var int |
|
19 | */ |
|
20 | private $height; |
|
21 | ||
22 | /** |
|
23 | * @var string |
|
24 | */ |
|
25 | private $material; |
|
26 | ||
27 | public function __construct(int $width, int $height) |
|
28 | { |
|
29 | $this->height = $height; |
|
30 | $this->width = $width; |
|
31 | $this->material = 'sticks'; |
|
32 | } |
|
33 | ||
34 | /** |
|
35 | * @return int |
|
36 | */ |
|
37 | public function getHeight(): int |
|
38 | { |
|
39 | return $this->height; |
|
40 | } |
|
41 | ||
42 | /** |
|
43 | * @return int |
|
44 | */ |
|
45 | public function getWidth(): int |
|
46 | { |
|
47 | return $this->width; |
|
48 | } |
|
49 | ||
50 | /** |
|
51 | * @return string |
|
52 | */ |
|
53 | public function getMaterial(): string |
|
54 | { |
|
55 | return $this->material; |
|
56 | } |
|
57 | } |
|
58 |
@@ 10-57 (lines=48) @@ | ||
7 | * Class StrawHouse |
|
8 | * @package codenixsv\Patterns\Creational\FactoryMethod |
|
9 | */ |
|
10 | class StrawHouse implements HouseInterface |
|
11 | { |
|
12 | /** |
|
13 | * @var int |
|
14 | */ |
|
15 | private $width; |
|
16 | ||
17 | /** |
|
18 | * @var int |
|
19 | */ |
|
20 | private $height; |
|
21 | ||
22 | /** |
|
23 | * @var string |
|
24 | */ |
|
25 | private $material; |
|
26 | ||
27 | public function __construct(int $width, int $height) |
|
28 | { |
|
29 | $this->height = $height; |
|
30 | $this->width = $width; |
|
31 | $this->material = 'straws'; |
|
32 | } |
|
33 | ||
34 | /** |
|
35 | * @return int |
|
36 | */ |
|
37 | public function getHeight(): int |
|
38 | { |
|
39 | return $this->height; |
|
40 | } |
|
41 | ||
42 | /** |
|
43 | * @return int |
|
44 | */ |
|
45 | public function getWidth(): int |
|
46 | { |
|
47 | return $this->width; |
|
48 | } |
|
49 | ||
50 | /** |
|
51 | * @return string |
|
52 | */ |
|
53 | public function getMaterial(): string |
|
54 | { |
|
55 | return $this->material; |
|
56 | } |
|
57 | } |
|
58 |