1+ <?php
2+
3+ namespace PhpDesignPatterns \Creational \Builder ;
4+
5+ /**
6+ * Class ClassicWatchBuilder
7+ * @package PhpDesignPatterns\Creational\Builder
8+ */
9+ class ClassicWatchBuilder implements WatchBuilderInterface
10+ {
11+ /**
12+ * Instance of SportWatch.
13+ *
14+ * @var SportWatch
15+ */
16+ private $ watch ;
17+
18+ /**
19+ * @return mixed
20+ */
21+ public function createWatch ()
22+ {
23+ $ this ->setWatch (new ClassicWatch );
24+ return $ this ;
25+ }
26+
27+ /**
28+ * @return mixed
29+ */
30+ public function addBox ()
31+ {
32+ $ this ->watch ->addComponent ("Watch box " , new Components \Box ());
33+ return $ this ;
34+ }
35+
36+ /**
37+ * @return mixed
38+ */
39+ public function addHands ()
40+ {
41+ $ this ->watch ->addComponent ("Seconds hand " , new Components \Hand ());
42+ $ this ->watch ->addComponent ("Minutes hand " , new Components \Hand ());
43+ $ this ->watch ->addComponent ("Hours hand " , new Components \Hand ());
44+ return $ this ;
45+ }
46+
47+ /**
48+ * @return mixed
49+ */
50+ public function addBands ()
51+ {
52+ $ this ->watch ->addComponent ("Leather upper band " , new Components \Band ());
53+ $ this ->watch ->addComponent ("Leather lower band " , new Components \Band ());
54+ return $ this ;
55+ }
56+
57+ /**
58+ * @return mixed
59+ */
60+ public function addMovements ()
61+ {
62+ $ this ->watch ->addComponent ("Principal watch movement " , new Components \Movement ());
63+ $ this ->watch ->addComponent ("Date watch movement " , new Components \Movement ());
64+ return $ this ;
65+ }
66+
67+ /**
68+ * @return mixed
69+ */
70+ public function getWatch ()
71+ {
72+ return $ this ->watch ;
73+ }
74+
75+ /**
76+ * @param Watch $watch
77+ * @return ClassicWatchBuilder
78+ */
79+ public function setWatch (Watch $ watch )
80+ {
81+ $ this ->watch = $ watch ;
82+ return $ this ;
83+ }
84+ }
0 commit comments