File tree Expand file tree Collapse file tree 5 files changed +18
-34
lines changed
SandersW-LearningPHPDesignPatterns/Factory Expand file tree Collapse file tree 5 files changed +18
-34
lines changed Original file line number Diff line number Diff line change 99//GraphicFactory.php
1010include_once ('Creator.php ' );
1111include_once ('GraphicProduct.php ' );
12+
1213class GraphicFactory extends Creator {
1314
1415 protected function factoryMethod () {
Original file line number Diff line number Diff line change 11<?php
22//GraphicProduct.php
33include_once ('Product.php ' );
4+
45class GraphicProduct implements Product {
56
67 private $ mfgProduct ;
8+
79 public function getProperties () {
810 $ this ->mfgProduct ="This is a graphic.<3 " ;
911 return $ this ->mfgProduct ;
1012 }
11-
1213}
Original file line number Diff line number Diff line change 11<?php
2- //TextProduct.php
3- include_once ('Product.php ' );
4- class TextProduct implements Product {
5-
6- private $ mfgProduct ;
7- public function getProperties ()
8- {
9- $ this ->mfgProduct ="This is text. " ;
10- return $ this ->mfgProduct ;
11- }
2+ //Product.php
3+ interface Product {
124
5+ public function getProperties ();
136}
Original file line number Diff line number Diff line change 11<?php
22
3- /*
4- * To change this license header, choose License Headers in Project Properties.
5- * To change this template file, choose Tools | Templates
6- * and open the template in the editor.
7- */
8-
3+ //TextFactory.php
94include_once ('Creator.php ' );
105include_once ('TextProduct.php ' );
116
127class TextFactory extends Creator {
138
149 protected function factoryMethod () {
15- $ product =new TextProduct ();
16- return ($ product ->getProperties ());
10+ $ product =new TextProduct ();
11+ return ($ product ->getProperties ());
1712 }
1813
19- }
20-
14+ }
Original file line number Diff line number Diff line change 11<?php
22
3- /*
4- * To change this license header, choose License Headers in Project Properties.
5- * To change this template file, choose Tools | Templates
6- * and open the template in the editor.
7- */
3+ //TextProduct.php
4+ include_once ('Product.php ' );
85
9- include_once ('Creator.php ' );
10- include_once ('TextProduct.php ' );
6+ class TextProduct implements Product {
117
12- class TextFactory extends Creator {
8+ private $ mfgProduct ;
139
14- protected function factoryMethod () {
15- $ product = new TextProduct () ;
16- return ( $ product -> getProperties ()) ;
10+ public function getProperties () {
11+ $ this -> mfgProduct = " This is text. " ;
12+ return $ this -> mfgProduct ;
1713 }
1814
19- }
20-
15+ }
You can’t perform that action at this time.
0 commit comments