diff --git a/TemplateMethod/BeachJourney.php b/TemplateMethod/BeachJourney.php index cec7bab..6370ef2 100644 --- a/TemplateMethod/BeachJourney.php +++ b/TemplateMethod/BeachJourney.php @@ -1,9 +1,5 @@ buyAFlight(); $this->takePlane(); @@ -53,24 +48,27 @@ abstract class Journey */ protected function buyGift() { - } - // this method will be unknown by subclasses (better) + /** + * this method will be unknown by subclasses (better) + */ private function buyAFlight() { echo "Buying a flight\n"; } - // sbclasses will get access to this method but cannot override it and - // compromise this algorithm (warning : cause of cyclic depedencies) + /** + * sbclasses will get access to this method but cannot override it and + * compromise this algorithm (warning : cause of cyclic dependencies) + */ final protected function takePlane() { echo "Taking the plane\n"; } // A note regarding the keyword "final" : don't use it when you start coding : - // add it after you narrow and know exacly what change and what remain unchanged - // in this algorithm. + // add it after you narrow and know exactly what change and what remain unchanged + // in this algorithm. // [abstract] x [3 access] x [final] = 12 combinations, it can be hard ! -} \ No newline at end of file +} diff --git a/Tests/TemplateMethod/JourneyTest.php b/Tests/TemplateMethod/JourneyTest.php index fcfc4e6..bc87062 100644 --- a/Tests/TemplateMethod/JourneyTest.php +++ b/Tests/TemplateMethod/JourneyTest.php @@ -23,7 +23,7 @@ class JourneyTest extends \PHPUnit_Framework_TestCase public function testCity() { - $journey = new TemplateMethod\CityJouney(); + $journey = new TemplateMethod\CityJourney(); $this->expectOutputRegex('#drink#'); $journey->takeATrip(); }