@@ -17,7 +17,7 @@ |
||
17 | 17 | { |
18 | 18 | $content = ''; |
19 | 19 | foreach ($config as $name => $section) { |
20 | - $content .= Yaml::dump([$name => $section], 4).PHP_EOL; |
|
20 | + $content .= Yaml::dump([$name => $section], 4) . PHP_EOL; |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | return $content; |
@@ -66,7 +66,7 @@ |
||
66 | 66 | */ |
67 | 67 | public function getConfigurationFilepath() |
68 | 68 | { |
69 | - return $this->configFilepath ?: $this->rootDirectory.DIRECTORY_SEPARATOR.$this->filename; |
|
69 | + return $this->configFilepath ?: $this->rootDirectory . DIRECTORY_SEPARATOR . $this->filename; |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -38,20 +38,20 @@ |
||
38 | 38 | SIGNATURE; |
39 | 39 | |
40 | 40 | $this |
41 | - ->setDisplayName($signature."\n".'Hogosha Monitoring Tool') |
|
41 | + ->setDisplayName($signature . "\n" . 'Hogosha Monitoring Tool') |
|
42 | 42 | ->setName('monitor') |
43 | 43 | ->setVersion(Monitor::VERSION) |
44 | 44 | ->addOption('config', 'c', Option::OPTIONAL_VALUE, 'Config file path', rtrim(getcwd(), DIRECTORY_SEPARATOR)) |
45 | 45 | ->beginCommand('init') |
46 | 46 | ->setDescription('Create a default configuration file if you do not have one') |
47 | - ->setHandler(function () use ($configurationLoader, $configurationDumper, $filesystem) { |
|
47 | + ->setHandler(function() use ($configurationLoader, $configurationDumper, $filesystem) { |
|
48 | 48 | return new InitHandler($configurationLoader, $configurationDumper, $filesystem); |
49 | 49 | }) |
50 | 50 | ->setHelp('php <info>bin/monitor</info> init') |
51 | 51 | ->end() |
52 | 52 | ->beginCommand('run') |
53 | 53 | ->setDescription('Launch the monitor process') |
54 | - ->setHandler(function () use ($configurationLoader) { |
|
54 | + ->setHandler(function() use ($configurationLoader) { |
|
55 | 55 | return new RunHandler($configurationLoader); |
56 | 56 | }) |
57 | 57 | ->setHelp('php <info>bin/monitor</info> init') |
@@ -37,7 +37,7 @@ |
||
37 | 37 | $result->getStatusCode(), |
38 | 38 | $result->getName(), |
39 | 39 | $result->getReponseTime() |
40 | - )."\n" |
|
40 | + ) . "\n" |
|
41 | 41 | ); |
42 | 42 | } |
43 | 43 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public function testExistingConfigurationFile() |
26 | 26 | { |
27 | - $file = sys_get_temp_dir().DIRECTORY_SEPARATOR.Monitor::CONFIG_FILENAME; |
|
27 | + $file = sys_get_temp_dir() . DIRECTORY_SEPARATOR . Monitor::CONFIG_FILENAME; |
|
28 | 28 | |
29 | 29 | // Dump the configuration set by the enduser |
30 | 30 | $configuration = [ |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | |
42 | 42 | $content = ''; |
43 | 43 | foreach ($configuration as $name => $section) { |
44 | - $content .= Yaml::dump([$name => $section], 4).PHP_EOL; |
|
44 | + $content .= Yaml::dump([$name => $section], 4) . PHP_EOL; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | file_put_contents($file, $content); |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | */ |
109 | 109 | public function testDefaultConfigurationFile() |
110 | 110 | { |
111 | - $testFile = sys_get_temp_dir().DIRECTORY_SEPARATOR.Monitor::CONFIG_FILENAME; |
|
111 | + $testFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . Monitor::CONFIG_FILENAME; |
|
112 | 112 | |
113 | 113 | $configurationLoader = new ConfigurationLoader(); |
114 | 114 | $configurationDumper = new ConfigurationDumper(); |
@@ -18,10 +18,10 @@ |
||
18 | 18 | return file_exists($file) ? include $file : false; |
19 | 19 | } |
20 | 20 | |
21 | -if ((!$loader = includeIfExists(__DIR__.'/../vendor/autoload.php')) && (!$loader = includeIfExists(__DIR__.'/../../../autoload.php'))) { |
|
22 | - echo 'You must set up the project dependencies, run the following commands:'.PHP_EOL. |
|
23 | - 'curl -sS https://getcomposer.org/installer | php'.PHP_EOL. |
|
24 | - 'php composer.phar install'.PHP_EOL; |
|
21 | +if ((!$loader = includeIfExists(__DIR__ . '/../vendor/autoload.php')) && (!$loader = includeIfExists(__DIR__ . '/../../../autoload.php'))) { |
|
22 | + echo 'You must set up the project dependencies, run the following commands:' . PHP_EOL . |
|
23 | + 'curl -sS https://getcomposer.org/installer | php' . PHP_EOL . |
|
24 | + 'php composer.phar install' . PHP_EOL; |
|
25 | 25 | exit(1); |
26 | 26 | } |
27 | 27 |
@@ -4,7 +4,6 @@ |
||
4 | 4 | |
5 | 5 | use Hogosha\Monitor\Guesser\StatusGuesser; |
6 | 6 | use Hogosha\Monitor\Model\Result; |
7 | -use Hogosha\Monitor\Model\ResultCollection; |
|
8 | 7 | use Hogosha\Monitor\Model\UrlInfo; |
9 | 8 | |
10 | 9 | /** |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * Constructor. |
40 | 40 | * |
41 | 41 | * @param UrlProvider $urlProvider |
42 | - * @param GuzzleClient $client |
|
42 | + * @param Client $client |
|
43 | 43 | */ |
44 | 44 | public function __construct(UrlProvider $urlProvider, Client $client) |
45 | 45 | { |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | /** |
51 | 51 | * run. |
52 | 52 | * |
53 | - * @return array |
|
53 | + * @return ResultCollection |
|
54 | 54 | */ |
55 | 55 | public function run() |
56 | 56 | { |
@@ -16,9 +16,7 @@ |
||
16 | 16 | namespace Hogosha\Monitor\Runner; |
17 | 17 | |
18 | 18 | use GuzzleHttp\Client; |
19 | -use GuzzleHttp\Exception\ConnectException; |
|
20 | 19 | use GuzzleHttp\Pool; |
21 | -use GuzzleHttp\Promise; |
|
22 | 20 | use GuzzleHttp\Psr7\Request; |
23 | 21 | use GuzzleHttp\TransferStats; |
24 | 22 | use Hogosha\Monitor\Client\GuzzleClient; |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | |
62 | 62 | $resultCollection = new ResultCollection(); |
63 | 63 | |
64 | - $requests = function () use ($urls, $client, $resultCollection) { |
|
64 | + $requests = function() use ($urls, $client, $resultCollection) { |
|
65 | 65 | foreach ($urls as $url) { |
66 | - yield function () use ($client, $url, $resultCollection) { |
|
66 | + yield function() use ($client, $url, $resultCollection) { |
|
67 | 67 | return $client->sendAsync( |
68 | 68 | new Request( |
69 | 69 | $url->getMethod(), |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | ), |
73 | 73 | [ |
74 | 74 | 'timeout' => $url->getTimeout(), |
75 | - 'on_stats' => function (TransferStats $tranferStats) use ($url, $resultCollection) { |
|
75 | + 'on_stats' => function(TransferStats $tranferStats) use ($url, $resultCollection) { |
|
76 | 76 | |
77 | 77 | if ($tranferStats->hasResponse()) { |
78 | 78 | $statusCode = $tranferStats->getResponse()->getStatusCode(); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public function compile() |
32 | 32 | { |
33 | - $pharFilePath = dirname(__FILE__).'/../../build/monitor.phar'; |
|
33 | + $pharFilePath = dirname(__FILE__) . '/../../build/monitor.phar'; |
|
34 | 34 | if (file_exists($pharFilePath)) { |
35 | 35 | unlink($pharFilePath); |
36 | 36 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | $phar->setSignatureAlgorithm(\Phar::SHA1); |
42 | 42 | |
43 | 43 | $phar->startBuffering(); |
44 | - $root = __DIR__.'/../..'; |
|
44 | + $root = __DIR__ . '/../..'; |
|
45 | 45 | |
46 | 46 | $finder = new Finder(); |
47 | 47 | $finder->files() |
@@ -52,33 +52,33 @@ discard block |
||
52 | 52 | ->exclude('Tests') |
53 | 53 | ->exclude('tests') |
54 | 54 | ->exclude('docs') |
55 | - ->in($root.'/src') |
|
56 | - ->in($root.'/vendor/guzzlehttp') |
|
57 | - ->in($root.'/vendor/eljam') |
|
58 | - ->in($root.'/vendor/hogosha') |
|
59 | - ->in($root.'/vendor/webmozart') |
|
60 | - ->in($root.'/vendor/psr') |
|
61 | - ->in($root.'/vendor/guzzle') |
|
62 | - ->in($root.'/vendor/symfony') |
|
55 | + ->in($root . '/src') |
|
56 | + ->in($root . '/vendor/guzzlehttp') |
|
57 | + ->in($root . '/vendor/eljam') |
|
58 | + ->in($root . '/vendor/hogosha') |
|
59 | + ->in($root . '/vendor/webmozart') |
|
60 | + ->in($root . '/vendor/psr') |
|
61 | + ->in($root . '/vendor/guzzle') |
|
62 | + ->in($root . '/vendor/symfony') |
|
63 | 63 | ; |
64 | 64 | |
65 | 65 | foreach ($finder as $file) { |
66 | 66 | $this->addFile($phar, $file); |
67 | 67 | } |
68 | 68 | |
69 | - $this->addFile($phar, new \SplFileInfo($root.'/vendor/autoload.php')); |
|
70 | - $this->addFile($phar, new \SplFileInfo($root.'/vendor/composer/autoload_namespaces.php')); |
|
71 | - $this->addFile($phar, new \SplFileInfo($root.'/vendor/composer/autoload_psr4.php')); |
|
72 | - $this->addFile($phar, new \SplFileInfo($root.'/vendor/composer/autoload_classmap.php')); |
|
73 | - $this->addFile($phar, new \SplFileInfo($root.'/vendor/composer/autoload_files.php')); |
|
74 | - $this->addFile($phar, new \SplFileInfo($root.'/vendor/composer/autoload_real.php')); |
|
69 | + $this->addFile($phar, new \SplFileInfo($root . '/vendor/autoload.php')); |
|
70 | + $this->addFile($phar, new \SplFileInfo($root . '/vendor/composer/autoload_namespaces.php')); |
|
71 | + $this->addFile($phar, new \SplFileInfo($root . '/vendor/composer/autoload_psr4.php')); |
|
72 | + $this->addFile($phar, new \SplFileInfo($root . '/vendor/composer/autoload_classmap.php')); |
|
73 | + $this->addFile($phar, new \SplFileInfo($root . '/vendor/composer/autoload_files.php')); |
|
74 | + $this->addFile($phar, new \SplFileInfo($root . '/vendor/composer/autoload_real.php')); |
|
75 | 75 | |
76 | - if (file_exists($root.'/vendor/composer/include_paths.php')) { |
|
77 | - $this->addFile($phar, new \SplFileInfo($root.'/vendor/composer/include_paths.php')); |
|
76 | + if (file_exists($root . '/vendor/composer/include_paths.php')) { |
|
77 | + $this->addFile($phar, new \SplFileInfo($root . '/vendor/composer/include_paths.php')); |
|
78 | 78 | } |
79 | - $this->addFile($phar, new \SplFileInfo($root.'/vendor/composer/ClassLoader.php')); |
|
79 | + $this->addFile($phar, new \SplFileInfo($root . '/vendor/composer/ClassLoader.php')); |
|
80 | 80 | |
81 | - $binContent = file_get_contents($root.'/bin/monitor'); |
|
81 | + $binContent = file_get_contents($root . '/bin/monitor'); |
|
82 | 82 | $binContent = preg_replace('{^#!/usr/bin/env php\s*}', '', $binContent); |
83 | 83 | $phar->addFromString('bin/monitor', $binContent); |
84 | 84 | |
@@ -90,12 +90,12 @@ discard block |
||
90 | 90 | |
91 | 91 | protected function addFile(\Phar $phar, \SplFileInfo $file, $strip = true) |
92 | 92 | { |
93 | - $path = str_replace(dirname(dirname(__DIR__)).DIRECTORY_SEPARATOR, '', $file->getRealPath()); |
|
93 | + $path = str_replace(dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR, '', $file->getRealPath()); |
|
94 | 94 | $content = file_get_contents($file); |
95 | 95 | if ($strip) { |
96 | 96 | $content = self::stripWhitespace($content); |
97 | 97 | } elseif ('LICENSE' === basename($file)) { |
98 | - $content = "\n".$content."\n"; |
|
98 | + $content = "\n" . $content . "\n"; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | if ($path === 'src/Monitor.php') { |