Skip to content

Commit 8b82ed1

Browse files
author
Dominik Liebler
committed
cs
1 parent 8452c63 commit 8b82ed1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+97
-222
lines changed

Adapter/EBookAdapter.php

-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
<?php
22

3-
/*
4-
* DesignPatternPHP
5-
*/
6-
73
namespace DesignPatterns\Adapter;
84

95
/**

Builder/BikeBuilder.php

-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
<?php
22

3-
/*
4-
* DesignPatternPHP
5-
*/
6-
73
namespace DesignPatterns\Builder;
84

95
/**

Builder/Builder.php

+25-15
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
<?php
22

3-
/*
4-
* DesignPatternPHP
5-
*/
6-
73
namespace DesignPatterns\Builder;
84

95
/**
@@ -20,14 +16,28 @@
2016
*/
2117
interface Builder
2218
{
23-
24-
function createVehicle();
25-
26-
function addWheel();
27-
28-
function addEngine();
29-
30-
function addDoors();
31-
32-
function getVehicle();
33-
}
19+
/**
20+
* @return mixed
21+
*/
22+
public function createVehicle();
23+
24+
/**
25+
* @return mixed
26+
*/
27+
public function addWheel();
28+
29+
/**
30+
* @return mixed
31+
*/
32+
public function addEngine();
33+
34+
/**
35+
* @return mixed
36+
*/
37+
public function addDoors();
38+
39+
/**
40+
* @return mixed
41+
*/
42+
public function getVehicle();
43+
}

Builder/CarBuilder.php

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
<?php
22

3-
/*
4-
* DesignPatternPHP
5-
*/
6-
73
namespace DesignPatterns\Builder;
84

95
/**
@@ -42,5 +38,4 @@ public function getVehicle()
4238
{
4339
return $this->car;
4440
}
45-
46-
}
41+
}

Builder/Director.php

-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
<?php
22

3-
/*
4-
* DesignPatternPHP
5-
*/
6-
73
namespace DesignPatterns\Builder;
84

95
/**

Builder/Parts/Bike.php

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
<?php
22

3-
/*
4-
* DesignPatternPHP
5-
*/
6-
73
namespace DesignPatterns\Builder\Parts;
84

95
/**
106
* Bike is a bike
117
*/
128
class Bike extends Vehicle
139
{
14-
15-
}
10+
11+
}

Builder/Parts/Car.php

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
<?php
22

3-
/*
4-
* DesignPatternPHP
5-
*/
6-
73
namespace DesignPatterns\Builder\Parts;
84

95
/**
106
* Car is a car
117
*/
128
class Car extends Vehicle
139
{
14-
15-
}
10+
11+
}

Builder/Parts/Door.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
namespace DesignPatterns\Builder\Parts;
44

5+
/**
6+
* Class Door
7+
*/
58
class Door
69
{
7-
8-
}
10+
11+
}

Builder/Parts/Engine.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
namespace DesignPatterns\Builder\Parts;
44

5+
/**
6+
* Class Engine
7+
*/
58
class Engine
69
{
7-
8-
}
10+
11+
}

Builder/Parts/Vehicle.php

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
<?php
22

3-
/*
4-
* DesignPatternPHP
5-
*/
6-
73
namespace DesignPatterns\Builder\Parts;
84

95
/**
106
* VehicleInterface is a contract for a vehicle
117
*/
128
abstract class Vehicle
139
{
14-
10+
/**
11+
* @var array
12+
*/
1513
protected $data;
1614

15+
/**
16+
* @param string $key
17+
* @param mixed $value
18+
*/
1719
public function setPart($key, $value)
1820
{
1921
$this->data[$key] = $value;
2022
}
21-
22-
}
23+
}

ChainOfResponsibilities/ChainOfResponsibilities.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,4 @@ public function get($key)
9393
/**
9494
* In this example we could also add a abstract class and extend it to build Fast- and SlowStorage. That class would
9595
* then manage the chain and when the cache hits a "miss", it would check if there is a next handler
96-
*/
96+
*/

ChainOfResponsibilities/Handler.php

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
<?php
22

3-
/*
4-
* DesignPatternPHP
5-
*/
6-
73
namespace DesignPatterns\ChainOfResponsibilities;
84

95
/**
@@ -16,7 +12,9 @@
1612
*/
1713
abstract class Handler
1814
{
19-
15+
/**
16+
* @var null
17+
*/
2018
private $successor = null;
2119

2220
/**
@@ -69,4 +67,4 @@ final public function handle(Request $req)
6967
* @return bool true if the request has been processed
7068
*/
7169
abstract protected function processing(Request $req);
72-
}
70+
}

ChainOfResponsibilities/Request.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
<?php
22

3-
/*
4-
* DesignPatternPHP
5-
*/
6-
73
namespace DesignPatterns\ChainOfResponsibilities;
84

95
/**
@@ -20,4 +16,4 @@
2016
class Request
2117
{
2218
// getter and setter but I don't want to generate to much noise in handlers
23-
}
19+
}

ChainOfResponsibilities/Responsible/FastStorage.php

-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
<?php
22

3-
/*
4-
* DesignPatternPHP
5-
*/
6-
73
namespace DesignPatterns\ChainOfResponsibilities\Responsible;
84

95
use DesignPatterns\ChainOfResponsibilities\Handler;
@@ -33,5 +29,4 @@ protected function processing(Request $req)
3329

3430
return false;
3531
}
36-
3732
}

ChainOfResponsibilities/Responsible/SlowStorage.php

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
<?php
22

3-
/*
4-
* DesignPatternPHP
5-
*/
6-
73
namespace DesignPatterns\ChainOfResponsibilities\Responsible;
84

95
use DesignPatterns\ChainOfResponsibilities\Handler;
@@ -21,9 +17,14 @@
2117
*/
2218
class SlowStorage extends Handler
2319
{
24-
20+
/**
21+
* @var array
22+
*/
2523
protected $_data = array();
2624

25+
/**
26+
* @param array $data
27+
*/
2728
public function __construct($data = array())
2829
{
2930
$this->_data = $data;
@@ -34,11 +35,11 @@ protected function processing(Request $req)
3435
if ('get' === $req->verb) {
3536
if (array_key_exists($req->key, $this->_data)) {
3637
$req->response = $this->_data[$req->key];
38+
3739
return true;
3840
}
3941
}
4042

4143
return false;
4244
}
43-
4445
}

Command/Invoker.php

-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
<?php
22

3-
/*
4-
* DesignPatternPHP
5-
*/
6-
73
namespace DesignPatterns\Command;
84

95
/**

Command/Receiver.php

-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
<?php
22

3-
/*
4-
* DesignPatternPHP
5-
*/
6-
73
namespace DesignPatterns\Command;
84

95
/**

FactoryMethod/Bicycle.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/**
66
* Bicycle is a bicycle
77
*/
8-
class Bicycle implements Vehicle
8+
class Bicycle implements VehicleInterface
99
{
1010
/**
1111
* @var string

FactoryMethod/FactoryMethod.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ abstract class FactoryMethod
2828
*
2929
* @param string $type a generic type
3030
*
31-
* @return Vehicle a new vehicle
31+
* @return VehicleInterface a new vehicle
3232
*/
3333
abstract protected function createVehicle($type);
3434

@@ -37,7 +37,7 @@ abstract protected function createVehicle($type);
3737
*
3838
* @param int $type
3939
*
40-
* @return Vehicle a new vehicle
40+
* @return VehicleInterface a new vehicle
4141
*/
4242
public function create($type)
4343
{

FactoryMethod/Ferrari.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/**
66
* Ferrari is a italian car
77
*/
8-
class Ferrari implements Vehicle
8+
class Ferrari implements VehicleInterface
99
{
1010
/**
1111
* @var string

FactoryMethod/Porsche.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/**
66
* Porsche is a german car
77
*/
8-
class Porsche implements Vehicle
8+
class Porsche implements VehicleInterface
99
{
1010
/**
1111
* @var string

FactoryMethod/Vehicle.php FactoryMethod/VehicleInterface.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
namespace DesignPatterns\FactoryMethod;
44

55
/**
6-
* Vehicle is a contract for a vehicle
6+
* VehicleInterface is a contract for a vehicle
77
*/
8-
interface Vehicle
8+
interface VehicleInterface
99
{
1010
/**
1111
* sets the color of the vehicle
1212
*
1313
* @param string $rgb
1414
*/
15-
function setColor($rgb);
15+
public function setColor($rgb);
1616
}

0 commit comments

Comments
 (0)