File tree 6 files changed +53
-46
lines changed
6 files changed +53
-46
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ public function addDoors()
15
15
{
16
16
$ this ->car ->setPart ('rightDoor ' , new Parts \Door ());
17
17
$ this ->car ->setPart ('leftDoor ' , new Parts \Door ());
18
+ $ this ->car ->setPart ('trunkLid ' , new Parts \Door ());
18
19
}
19
20
20
21
public function addEngine ()
Original file line number Diff line number Diff line change 2
2
3
3
namespace DesignPatterns \Creational \Builder \Parts ;
4
4
5
- class Bike extends Vehicle
5
+ class Truck extends Vehicle
6
6
{
7
7
}
Original file line number Diff line number Diff line change @@ -44,9 +44,9 @@ BuilderInterface.php
44
44
:language: php
45
45
:linenos:
46
46
47
- BikeBuilder .php
47
+ TruckBuilder .php
48
48
49
- .. literalinclude :: BikeBuilder .php
49
+ .. literalinclude :: TruckBuilder .php
50
50
:language: php
51
51
:linenos:
52
52
@@ -62,9 +62,9 @@ Parts/Vehicle.php
62
62
:language: php
63
63
:linenos:
64
64
65
- Parts/Bike .php
65
+ Parts/Truck .php
66
66
67
- .. literalinclude :: Parts/Bike .php
67
+ .. literalinclude :: Parts/Truck .php
68
68
:language: php
69
69
:linenos:
70
70
Original file line number Diff line number Diff line change 2
2
3
3
namespace DesignPatterns \Creational \Builder \Tests ;
4
4
5
- use DesignPatterns \Creational \Builder \BikeBuilder ;
5
+ use DesignPatterns \Creational \Builder \TruckBuilder ;
6
6
use DesignPatterns \Creational \Builder \CarBuilder ;
7
7
use DesignPatterns \Creational \Builder \Director ;
8
8
9
9
class DirectorTest extends \PHPUnit_Framework_TestCase
10
10
{
11
11
public function testCanBuildBike ()
12
12
{
13
- $ bikeBuilder = new BikeBuilder ();
13
+ $ bikeBuilder = new TruckBuilder ();
14
14
$ newVehicle = (new Director ())->build ($ bikeBuilder );
15
15
16
- $ this ->assertInstanceOf ('DesignPatterns\Creational\Builder\Parts\Bike ' , $ newVehicle );
16
+ $ this ->assertInstanceOf ('DesignPatterns\Creational\Builder\Parts\Truck ' , $ newVehicle );
17
17
}
18
18
19
19
public function testCanBuildCar ()
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace DesignPatterns \Creational \Builder ;
4
+
5
+ use DesignPatterns \Creational \Builder \Parts \Vehicle ;
6
+
7
+ class TruckBuilder implements BuilderInterface
8
+ {
9
+ /**
10
+ * @var Parts\Truck
11
+ */
12
+ private $ truck ;
13
+
14
+ public function addDoors ()
15
+ {
16
+ $ this ->truck ->setPart ('rightDoor ' , new Parts \Door ());
17
+ $ this ->truck ->setPart ('leftDoor ' , new Parts \Door ());
18
+ }
19
+
20
+ public function addEngine ()
21
+ {
22
+ $ this ->truck ->setPart ('truckEngine ' , new Parts \Engine ());
23
+ }
24
+
25
+ public function addWheel ()
26
+ {
27
+ $ this ->truck ->setPart ('wheel1 ' , new Parts \Wheel ());
28
+ $ this ->truck ->setPart ('wheel2 ' , new Parts \Wheel ());
29
+ $ this ->truck ->setPart ('wheel3 ' , new Parts \Wheel ());
30
+ $ this ->truck ->setPart ('wheel4 ' , new Parts \Wheel ());
31
+ $ this ->truck ->setPart ('wheel5 ' , new Parts \Wheel ());
32
+ $ this ->truck ->setPart ('wheel6 ' , new Parts \Wheel ());
33
+ }
34
+
35
+ public function createVehicle ()
36
+ {
37
+ $ this ->truck = new Parts \Truck ();
38
+ }
39
+
40
+ public function getVehicle (): Vehicle
41
+ {
42
+ return $ this ->truck ;
43
+ }
44
+ }
You can’t perform that action at this time.
0 commit comments