Skip to content

Commit f6651ba

Browse files
author
Dominik Liebler
committed
cs
1 parent 9484868 commit f6651ba

File tree

9 files changed

+56
-173
lines changed

9 files changed

+56
-173
lines changed

Adapter/EBookInterface.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,17 @@
77
*/
88
interface EBookInterface
99
{
10-
function pressNext();
10+
/**
11+
* go to next page
12+
*
13+
* @return mixed
14+
*/
15+
public function pressNext();
1116

12-
function pressStart();
13-
}
17+
/**
18+
* start the book
19+
*
20+
* @return mixed
21+
*/
22+
public function pressStart();
23+
}

Builder/BikeBuilder.php

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,51 @@
55
/**
66
* BikeBuilder builds bike
77
*/
8-
class BikeBuilder implements Builder
8+
class BikeBuilder implements BuilderInterface
99
{
10-
10+
/**
11+
* @var Parts\Bike
12+
*/
1113
protected $bike;
1214

15+
/**
16+
* {@inheritdoc}
17+
*/
1318
public function addDoors()
1419
{
15-
20+
1621
}
1722

23+
/**
24+
* {@inheritdoc}
25+
*/
1826
public function addEngine()
1927
{
2028
$this->bike->setPart('engine', new Parts\Engine());
2129
}
2230

31+
/**
32+
* {@inheritdoc}
33+
*/
2334
public function addWheel()
2435
{
2536
$this->bike->setPart('forwardWheel', new Parts\Wheel());
2637
$this->bike->setPart('rearWheel', new Parts\Wheel());
2738
}
2839

40+
/**
41+
* {@inheritdoc}
42+
*/
2943
public function createVehicle()
3044
{
3145
$this->bike = new Parts\Bike();
3246
}
3347

48+
/**
49+
* {@inheritdoc}
50+
*/
3451
public function getVehicle()
3552
{
3653
return $this->bike;
3754
}
38-
39-
}
55+
}

Builder/Builder.php renamed to Builder/BuilderInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* Note: Builders have often a fluent interface, see the mock builder of
1515
* PHPUnit for example.
1616
*/
17-
interface Builder
17+
interface BuilderInterface
1818
{
1919
/**
2020
* @return mixed

Builder/CarBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/**
66
* CarBuilder builds car
77
*/
8-
class CarBuilder implements Builder
8+
class CarBuilder implements BuilderInterface
99
{
1010
/**
1111
* @var Parts\Car

Builder/Director.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,12 @@ class Director
1414

1515
/**
1616
* The director don't know 'bout concrete part
17+
*
18+
* @param BuilderInterface $builder
19+
*
20+
* @return Parts\Vehicle
1721
*/
18-
public function build(Builder $builder)
22+
public function build(BuilderInterface $builder)
1923
{
2024
$builder->createVehicle();
2125
$builder->addDoors();
@@ -24,5 +28,4 @@ public function build(Builder $builder)
2428

2529
return $builder->getVehicle();
2630
}
27-
28-
}
31+
}

ChainOfResponsibilities/ChainOfResponsibilities.php

Lines changed: 0 additions & 96 deletions
This file was deleted.

ChainOfResponsibilities/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# chain of responsibilities
2+
3+
## Purpose:
4+
5+
To build a chain of objects to handle a call. if one object cannot handle a call, it delegates the call to the next
6+
in the chain and so forth
7+
8+
## Examples:
9+
10+
* logging framework
11+
* spam filter
12+
Caching: first object is an instance of e.g. a Memcached Interface, if that "misses" it delegates the call to the database interface
13+
* Yii Framework: CFilterChain is a chain of controller action filters. the executing point is passed from one filter to the next along the chain, and only if all filters say "yes", the action can be invoked at last.

Tests/Builder/DirectorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function getBuilder()
3333
*
3434
* @dataProvider getBuilder
3535
*/
36-
public function testBuild(\DesignPatterns\Builder\Builder $builder)
36+
public function testBuild(\DesignPatterns\Builder\BuilderInterface $builder)
3737
{
3838
$newVehicle = $this->director->build($builder);
3939
$this->assertInstanceOf('DesignPatterns\Builder\Parts\Vehicle', $newVehicle);

Tests/Iterator/IteratorTest.php

Lines changed: 0 additions & 63 deletions
This file was deleted.

0 commit comments

Comments
 (0)