2013-05-11 16:13:43 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace DesignPatterns\Facade;
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
2013-05-11 16:20:55 +02:00
|
|
|
*
|
2013-05-11 16:13:43 +02:00
|
|
|
*/
|
2013-05-11 16:43:14 +02:00
|
|
|
class Facade
|
2013-05-11 16:13:43 +02:00
|
|
|
{
|
2013-09-11 16:28:06 +02:00
|
|
|
/**
|
|
|
|
* @var OsInterface
|
|
|
|
*/
|
|
|
|
protected $os;
|
2013-05-11 16:13:43 +02:00
|
|
|
|
2013-09-11 16:28:06 +02:00
|
|
|
/**
|
|
|
|
* @var BiosInterface
|
|
|
|
*/
|
2013-05-11 16:13:43 +02:00
|
|
|
protected $bios;
|
|
|
|
|
2013-05-11 16:20:55 +02:00
|
|
|
/**
|
|
|
|
* This is the perfect time to use a dependency injection container
|
2013-11-14 17:05:27 +01:00
|
|
|
* to create an instance of this class
|
2013-09-11 16:28:06 +02:00
|
|
|
*
|
|
|
|
* @param BiosInterface $bios
|
|
|
|
* @param OsInterface $os
|
2013-05-11 16:20:55 +02:00
|
|
|
*/
|
2013-05-11 16:13:43 +02:00
|
|
|
public function __construct(BiosInterface $bios, OsInterface $os)
|
|
|
|
{
|
|
|
|
$this->bios = $bios;
|
2013-09-11 16:28:06 +02:00
|
|
|
$this->os = $os;
|
2013-05-11 16:13:43 +02:00
|
|
|
}
|
|
|
|
|
2013-09-11 16:28:06 +02:00
|
|
|
/**
|
|
|
|
* turn on the system
|
|
|
|
*/
|
2013-05-11 16:13:43 +02:00
|
|
|
public function turnOn()
|
|
|
|
{
|
|
|
|
$this->bios->execute();
|
|
|
|
$this->bios->waitForKeyPress();
|
2013-09-11 16:28:06 +02:00
|
|
|
$this->bios->launch($this->os);
|
2013-05-11 16:13:43 +02:00
|
|
|
}
|
|
|
|
|
2013-09-11 16:28:06 +02:00
|
|
|
/**
|
|
|
|
* turn off the system
|
|
|
|
*/
|
2013-05-11 16:13:43 +02:00
|
|
|
public function turnOff()
|
|
|
|
{
|
2013-09-11 16:28:06 +02:00
|
|
|
$this->os->halt();
|
2013-05-11 16:13:43 +02:00
|
|
|
$this->bios->powerDown();
|
|
|
|
}
|
2013-09-11 16:28:06 +02:00
|
|
|
}
|