| 1 | <?php |
||
| 13 | class Detector |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * @var array data like environment and console arguments |
||
| 17 | */ |
||
| 18 | protected $data; |
||
| 19 | /** |
||
| 20 | * @var array list with all allowed environments |
||
| 21 | */ |
||
| 22 | private $_envs = [ |
||
| 23 | 'console' => 'cli', |
||
| 24 | 'browser' => 'server', |
||
| 25 | ]; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Initialize current environment and set some useful data. |
||
| 29 | */ |
||
| 30 | public function __construct() |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Overloading method for getting element value from data array. |
||
| 37 | * |
||
| 38 | * @param string $name data storage key name |
||
| 39 | * @return mixed|null the value of data key |
||
| 40 | */ |
||
| 41 | public function __get($name) |
||
| 47 | |||
| 48 | /** |
||
| 49 | * Detect an environment in which is running the script. |
||
| 50 | * |
||
| 51 | * @return void |
||
| 52 | */ |
||
| 53 | public function detect() |
||
| 61 | } |
||
| 62 |