| 1 | <?php |
||
| 11 | class PlatformLocatorFactory implements LocatorFactoryInterface |
||
| 12 | { |
||
| 13 | /** @type \Nubs\Which\LocatorFactory\LocatorFactoryInterface The platform-specific factory. */ |
||
| 14 | private $_platformFactory; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Creates the factory to wrap the platform-specific factory. |
||
| 18 | * |
||
| 19 | * @api |
||
| 20 | * @param \Icecave\Isolator\Isolator $isolator The isolator object to |
||
| 21 | * override environment variable lookup. |
||
| 22 | */ |
||
| 23 | public function __construct(Isolator $isolator = null) |
||
| 24 | { |
||
| 25 | if ($isolator ? $isolator->defined('PHP_WINDOWS_VERSION_BUILD') : defined('PHP_WINDOWS_VERSION_BUILD')) { |
||
| 26 | $this->_platformFactory = new WindowsLocatorFactory(); |
||
| 27 | } else { |
||
| 28 | $this->_platformFactory = new PosixLocatorFactory(); |
||
| 29 | } |
||
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * Create a locator using the platform-specific factory. |
||
| 34 | * |
||
| 35 | * @api |
||
| 36 | * @param \Habitat\Environment\Environment $environment The environment |
||
| 37 | * variable wrapper. Defaults to null which just uses PHP's built-in |
||
| 38 | * getenv. |
||
| 39 | * @return \Nubs\Which\Locator The locator. |
||
| 40 | */ |
||
| 41 | public function create(Environment $environment = null) |
||
| 45 | } |
||
| 46 |