| @@ 10-38 (lines=29) @@ | ||
| 7 | * @since 2016/01/26 |
|
| 8 | * @version 0.7 |
|
| 9 | */ |
|
| 10 | class BrowserOutputter implements IOutputter |
|
| 11 | { |
|
| 12 | /** |
|
| 13 | * https://github.com/php/php-src/tree/master/sapi |
|
| 14 | * PHP7以前のものは対応しない |
|
| 15 | * @var SAPIリスト |
|
| 16 | */ |
|
| 17 | private $sapis = [ |
|
| 18 | 'apache2handler' => 'http', |
|
| 19 | 'cgi' => 'http', |
|
| 20 | 'cli' => 'console', |
|
| 21 | 'fpm' => 'http', |
|
| 22 | 'embed' => 'unsupported', |
|
| 23 | 'litespeed' => 'unsupported', |
|
| 24 | 'phpdbg' => 'unsupported', |
|
| 25 | 'tests' => 'unsupported' |
|
| 26 | ]; |
|
| 27 | ||
| 28 | /** |
|
| 29 | * {@inheritdoc} |
|
| 30 | */ |
|
| 31 | public function write($text) |
|
| 32 | { |
|
| 33 | $sapi = php_sapi_name(); |
|
| 34 | if (array_key_exists($sapi, $this->sapis) && $this->sapis[$sapi] === 'http') { |
|
| 35 | echo $text . "<br>"; |
|
| 36 | } |
|
| 37 | } |
|
| 38 | } |
|
| 39 | ||
| @@ 10-38 (lines=29) @@ | ||
| 7 | * @since 2016/01/26 |
|
| 8 | * @version 0.7 |
|
| 9 | */ |
|
| 10 | class ConsoleOutputter implements IOutputter |
|
| 11 | { |
|
| 12 | /** |
|
| 13 | * https://github.com/php/php-src/tree/master/sapi |
|
| 14 | * PHP7以前のものは対応しない |
|
| 15 | * @var SAPIリスト |
|
| 16 | */ |
|
| 17 | private $sapis = [ |
|
| 18 | 'apache2handler' => 'http', |
|
| 19 | 'cgi' => 'http', |
|
| 20 | 'cli' => 'console', |
|
| 21 | 'fpm' => 'http', |
|
| 22 | 'embed' => 'unsupported', |
|
| 23 | 'litespeed' => 'unsupported', |
|
| 24 | 'phpdbg' => 'unsupported', |
|
| 25 | 'tests' => 'unsupported' |
|
| 26 | ]; |
|
| 27 | ||
| 28 | /** |
|
| 29 | * {@inheritdoc} |
|
| 30 | */ |
|
| 31 | public function write($text) |
|
| 32 | { |
|
| 33 | $sapi = php_sapi_name(); |
|
| 34 | if (array_key_exists($sapi, $this->sapis) && $this->sapis[$sapi] === 'console') { |
|
| 35 | echo $text . PHP_EOL; |
|
| 36 | } |
|
| 37 | } |
|
| 38 | } |
|
| 39 | ||