File tree 20 files changed +44
-44
lines changed
07-parameterizedFactoryMethod.php
20 files changed +44
-44
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ class Hello
6
6
public function greeting ()
7
7
{
8
8
$ ko = new Korean ;
9
- return $ ko -> text ();
9
+ return $ ko-> text ();
10
10
}
11
11
}
12
12
?>
Original file line number Diff line number Diff line change @@ -5,12 +5,12 @@ class Hello
5
5
6
6
public function __construct ($ obj )
7
7
{
8
- $ this -> korean = $ obj ;
8
+ $ this -> korean = $ obj ;
9
9
}
10
10
11
11
public function greeting ()
12
12
{
13
- return $ this -> korean -> text ();
13
+ return $ this -> korean -> text ();
14
14
}
15
15
}
16
16
Original file line number Diff line number Diff line change 6
6
7
7
$ obj = new Hello ($ korean );
8
8
9
- echo $ obj -> greeting ();
9
+ echo $ obj-> greeting ();
10
10
?>
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ class CustomersController {
46
46
```
47
47
<h2>Customers</h2>
48
48
<ul>
49
- <?php foreach ($this -> customers as $customer): ?>
49
+ <?php foreach ($this-> customers as $customer): ?>
50
50
<li><?= $customer['name'] ?></li>
51
51
<?php endforeach; ?>
52
52
</ul>
@@ -107,12 +107,12 @@ class CustomersController extends AbstractActionController {
107
107
protected $customerRepository;
108
108
109
109
public function __construct(CustomerRepositoryInterface $repository) {
110
- $this -> $customerRepository = $repository;
110
+ $this-> $customerRepository = $repository;
111
111
}
112
112
113
113
public function indexAction() {
114
114
return [
115
- 'users' => $this -> customerRepository -> getAll();
115
+ 'users' => $this-> customerRepository-> getAll();
116
116
];
117
117
}
118
118
}
Original file line number Diff line number Diff line change @@ -14,10 +14,10 @@ public function greeting()
14
14
$ obj5 = new Hello ;
15
15
16
16
17
- echo $ obj1 -> greeting ();
18
- echo $ obj2 -> greeting ();
19
- echo $ obj3 -> greeting ();
20
- echo $ obj4 -> greeting ();
21
- echo $ obj5 -> greeting ();
17
+ echo $ obj1-> greeting ();
18
+ echo $ obj2-> greeting ();
19
+ echo $ obj3-> greeting ();
20
+ echo $ obj4-> greeting ();
21
+ echo $ obj5-> greeting ();
22
22
23
23
?>
Original file line number Diff line number Diff line change @@ -14,6 +14,6 @@ public function conf()
14
14
15
15
16
16
$ obj = new GlobalVariableSideEffectLisk ;
17
- print_r ($ obj -> conf ());
17
+ print_r ($ obj-> conf ());
18
18
19
19
?>
Original file line number Diff line number Diff line change 5
5
$ obj2 = Config::getInstance ();
6
6
echo "<br> " ;
7
7
$ obj3 = new Config ();
8
- $ obj3 -> getInstance ();
8
+ $ obj3-> getInstance ();
9
9
echo "<br> " ;
10
10
$ obj4 = new Config ();
11
- $ obj4 -> getInstance ();
11
+ $ obj4-> getInstance ();
12
12
13
13
?>
Original file line number Diff line number Diff line change 4
4
$ obj1 = Config::getInstance ();
5
5
$ obj2 = Config::getInstance ();
6
6
$ obj3 = new Config ();
7
- $ obj3 -> getInstance ();
7
+ $ obj3-> getInstance ();
8
8
$ obj4 = new Config ();
9
- $ obj4 -> getInstance ();
9
+ $ obj4-> getInstance ();
10
10
11
11
?>
Original file line number Diff line number Diff line change 10
10
echo Config::get ();
11
11
12
12
$ obj = new Config ();
13
- $ obj -> set ("world<br> " );
14
- echo $ obj -> get ();
13
+ $ obj-> set ("world<br> " );
14
+ echo $ obj-> get ();
15
15
echo Config::get ();
16
16
17
17
Original file line number Diff line number Diff line change 22
22
class UsersController {
23
23
public function indexAction() {
24
24
$repo = new UserRepository();
25
- $users = $repo -> getAll();
25
+ $users = $repo-> getAll();
26
26
return $users;
27
27
}
28
28
}
Original file line number Diff line number Diff line change 3
3
class CustomerFactory {
4
4
protected $accountManagerRepo;
5
5
public function __construct(AccountManagerRepository $repo) {
6
- $this -> accountManagerRepo = $repo;
6
+ $this-> accountManagerRepo = $repo;
7
7
}
8
8
9
9
public function createCustomer($name) {
10
10
$customer = new Customer();
11
- $customer -> setName($name);
12
- $customer -> setCreditLimit(0);
13
- $customer -> setStatus('pending');
14
- $customer -> setAccountManager(
15
- $this -> accountManagerRepo -> getRandom()
11
+ $customer-> setName($name);
12
+ $customer-> setCreditLimit(0);
13
+ $customer-> setStatus('pending');
14
+ $customer-> setAccountManager(
15
+ $this-> accountManagerRepo-> getRandom()
16
16
);
17
17
return $customer;
18
18
}
@@ -32,9 +32,9 @@ static factory is made static method only
32
32
```
33
33
class CustomerFactory {
34
34
public static function createCustomer($name) {
35
- $customer -> setName($name);
36
- $customer -> setCreditLimit(0);
37
- $customer -> setStatus('pending');
35
+ $customer-> setName($name);
36
+ $customer-> setCreditLimit(0);
37
+ $customer-> setStatus('pending');
38
38
39
39
return $customer;
40
40
}
Original file line number Diff line number Diff line change 4
4
5
5
$ fac = new Factory ;
6
6
7
- $ pro = $ fac -> create ();
8
- $ pro -> name ();
7
+ $ pro = $ fac-> create ();
8
+ $ pro-> name ();
9
9
10
10
?>
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ abstract class Factory
3
3
{
4
4
public final function create ()
5
5
{
6
- return $ this -> createProduct ();
6
+ return $ this -> createProduct ();
7
7
}
8
8
9
9
abstract public function createProduct ();
Original file line number Diff line number Diff line change 4
4
5
5
$ fac = new Factory ;
6
6
7
- $ pro = $ fac -> create ();
8
- $ pro -> name ();
7
+ $ pro = $ fac-> create ();
8
+ $ pro-> name ();
9
9
10
10
?>
Original file line number Diff line number Diff line change 1
1
<?php
2
2
public final function create ()
3
3
{
4
- return $ this -> createProduct ();
4
+ return $ this -> createProduct ();
5
5
}
6
6
7
7
?>
Original file line number Diff line number Diff line change 1
1
<?php
2
2
public final function create ()
3
3
{
4
- return $ this -> createProduct ();
4
+ return $ this -> createProduct ();
5
5
}
6
6
7
7
?>
Original file line number Diff line number Diff line change 5
5
require "ProductFactory.php " ;
6
6
7
7
$ fac = new ProductFactory ;
8
- $ pro = $ fac -> create ();
9
- $ pro -> name ();
8
+ $ pro = $ fac-> create ();
9
+ $ pro-> name ();
10
10
11
11
?>
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ abstract class Factory
3
3
{
4
4
public final function create ($ model )
5
5
{
6
- return $ this -> createProduct ($ model );
6
+ return $ this -> createProduct ($ model );
7
7
}
8
8
9
9
abstract public function createProduct ($ model );
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ abstract class Factory
3
3
{
4
4
public final function create ($ model )
5
5
{
6
- return $ this -> createProduct ($ model );
6
+ return $ this -> createProduct ($ model );
7
7
}
8
8
9
9
abstract public function createProduct ($ model );
Original file line number Diff line number Diff line change 5
5
require "ProductFactory.php " ;
6
6
7
7
$ fac = new ProductFactory ;
8
- $ pro = $ fac -> create ("Apple " );
9
- $ pro -> name ();
8
+ $ pro = $ fac-> create ("Apple " );
9
+ $ pro-> name ();
10
10
11
11
echo "<br> " ;
12
12
13
- $ pro = $ fac -> create ("MS " );
14
- $ pro -> name ();
13
+ $ pro = $ fac-> create ("MS " );
14
+ $ pro-> name ();
15
15
16
16
?>
You can’t perform that action at this time.
0 commit comments