diff --git a/Structural/Facade/BiosInterface.php b/Structural/Facade/BiosInterface.php
index 8f1aa01..ba6bdbe 100644
--- a/Structural/Facade/BiosInterface.php
+++ b/Structural/Facade/BiosInterface.php
@@ -2,30 +2,13 @@
namespace DesignPatterns\Structural\Facade;
-/**
- * Interface BiosInterface.
- */
interface BiosInterface
{
- /**
- * Execute the BIOS.
- */
public function execute();
- /**
- * Wait for halt.
- */
public function waitForKeyPress();
- /**
- * Launches the OS.
- *
- * @param OsInterface $os
- */
public function launch(OsInterface $os);
- /**
- * Power down BIOS.
- */
public function powerDown();
}
diff --git a/Structural/Facade/Facade.php b/Structural/Facade/Facade.php
index f199600..bda8b46 100644
--- a/Structural/Facade/Facade.php
+++ b/Structural/Facade/Facade.php
@@ -7,17 +7,14 @@ class Facade
/**
* @var OsInterface
*/
- protected $os;
+ private $os;
/**
* @var BiosInterface
*/
- protected $bios;
+ private $bios;
/**
- * This is the perfect time to use a dependency injection container
- * to create an instance of this class.
- *
* @param BiosInterface $bios
* @param OsInterface $os
*/
@@ -27,9 +24,6 @@ class Facade
$this->os = $os;
}
- /**
- * Turn on the system.
- */
public function turnOn()
{
$this->bios->execute();
@@ -37,9 +31,6 @@ class Facade
$this->bios->launch($this->os);
}
- /**
- * Turn off the system.
- */
public function turnOff()
{
$this->os->halt();
diff --git a/Structural/Facade/OsInterface.php b/Structural/Facade/OsInterface.php
index d8171e4..1b3a93e 100644
--- a/Structural/Facade/OsInterface.php
+++ b/Structural/Facade/OsInterface.php
@@ -2,13 +2,9 @@
namespace DesignPatterns\Structural\Facade;
-/**
- * Interface OsInterface.
- */
interface OsInterface
{
- /**
- * Halt the OS.
- */
public function halt();
+
+ public function getName(): string;
}
diff --git a/Structural/Facade/Tests/FacadeTest.php b/Structural/Facade/Tests/FacadeTest.php
index 0247aaf..8c6a0a6 100644
--- a/Structural/Facade/Tests/FacadeTest.php
+++ b/Structural/Facade/Tests/FacadeTest.php
@@ -2,47 +2,34 @@
namespace DesignPatterns\Structural\Facade\Tests;
-use DesignPatterns\Structural\Facade\Facade as Computer;
+use DesignPatterns\Structural\Facade\Facade;
use DesignPatterns\Structural\Facade\OsInterface;
-/**
- * FacadeTest shows example of facades.
- */
class FacadeTest extends \PHPUnit_Framework_TestCase
{
- public function getComputer()
+ public function testComputerOn()
{
+ /** @var OsInterface|\PHPUnit_Framework_MockObject_MockObject $os */
+ $os = $this->createMock('DesignPatterns\Structural\Facade\OsInterface');
+
+ $os->method('getName')
+ ->will($this->returnValue('Linux'));
+
$bios = $this->getMockBuilder('DesignPatterns\Structural\Facade\BiosInterface')
- ->setMethods(array('launch', 'execute', 'waitForKeyPress'))
- ->disableAutoload()
- ->getMock();
- $operatingSys = $this->getMockBuilder('DesignPatterns\Structural\Facade\OsInterface')
- ->setMethods(array('getName'))
- ->disableAutoload()
- ->getMock();
+ ->setMethods(['launch', 'execute', 'waitForKeyPress'])
+ ->disableAutoload()
+ ->getMock();
+
$bios->expects($this->once())
- ->method('launch')
- ->with($operatingSys);
- $operatingSys
- ->expects($this->once())
- ->method('getName')
- ->will($this->returnValue('Linux'));
+ ->method('launch')
+ ->with($os);
- $facade = new Computer($bios, $operatingSys);
+ $facade = new Facade($bios, $os);
- return array(array($facade, $operatingSys));
- }
-
- /**
- * @param Computer $facade
- * @param OsInterface $os
- * @dataProvider getComputer
- */
- public function testComputerOn(Computer $facade, OsInterface $os)
- {
- // interface is simpler :
+ // the facade interface is simple
$facade->turnOn();
- // but I can access to lower component
+
+ // but you can also access the underlying components
$this->assertEquals('Linux', $os->getName());
}
}
diff --git a/Structural/Facade/uml/Facade.uml b/Structural/Facade/uml/Facade.uml
index d6bdd03..8835df8 100644
--- a/Structural/Facade/uml/Facade.uml
+++ b/Structural/Facade/uml/Facade.uml
@@ -1,24 +1,23 @@
-
-
- PHP
- \DesignPatterns\Structural\Facade\BiosInterface
-
- \DesignPatterns\Structural\Facade\BiosInterface
- \DesignPatterns\Structural\Facade\OsInterface
- \DesignPatterns\Structural\Facade\Facade
-
-
-
-
-
- \DesignPatterns\Structural\Facade\BiosInterface
-
-
- Fields
- Constants
- Constructors
- Methods
-
- private
-
-
+
+
+ PHP
+ \DesignPatterns\Structural\Facade\BiosInterface
+
+ \DesignPatterns\Structural\Facade\BiosInterface
+ \DesignPatterns\Structural\Facade\Facade
+ \DesignPatterns\Structural\Facade\OsInterface
+
+
+
+
+
+ \DesignPatterns\Structural\Facade\BiosInterface
+
+
+ Methods
+ Constants
+ Fields
+
+ private
+
+
diff --git a/Structural/Facade/uml/uml.png b/Structural/Facade/uml/uml.png
index da5097a..fcea5f2 100644
Binary files a/Structural/Facade/uml/uml.png and b/Structural/Facade/uml/uml.png differ
diff --git a/Structural/Facade/uml/uml.svg b/Structural/Facade/uml/uml.svg
index 2e7b400..a14db50 100644
--- a/Structural/Facade/uml/uml.svg
+++ b/Structural/Facade/uml/uml.svg
@@ -1,324 +1,653 @@
-
+