Skip to content
This repository has been archived by the owner on Jun 7, 2021. It is now read-only.

Commit

Permalink
[STYLE]
Browse files Browse the repository at this point in the history
  • Loading branch information
stevleibelt committed Nov 2, 2017
1 parent ea4cfbb commit 5fb3197
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 26 deletions.
4 changes: 2 additions & 2 deletions example/local/parse_all.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function dumpSectionIfThereIsSomeContent(array $lines = null, $name)
$parserBuilderFactory = new \Net\Bazzline\Component\ApacheServerStatusParser\Service\Builder\ParserBuilderFactory();
$storageBuilder = new \Net\Bazzline\Component\ApacheServerStatusParser\Service\Builder\LocalStorageBuilder();

$parserBuilder = $parserBuilderFactory->create();
$parserBuilder = $parserBuilderFactory->create();
//end of dependencies

//begin of business logic
Expand All @@ -66,7 +66,7 @@ function dumpSectionIfThereIsSomeContent(array $lines = null, $name)
$storageBuilder->selectParseModeAllUpfront();
$storageBuilder->build();

$listOfNameToElapsedTime['fetching'] = PHP_Timer::secondsToTimeString(
$listOfNameToElapsedTime['fetching'] = PHP_Timer::secondsToTimeString(
PHP_Timer::stop()
);

Expand Down
4 changes: 2 additions & 2 deletions example/local/parse_detail_only.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function dumpSectionIfThereIsSomeContent(array $lines = null, $name)
$parserBuilderFactory = new \Net\Bazzline\Component\ApacheServerStatusParser\Service\Builder\ParserBuilderFactory();
$storageBuilder = new \Net\Bazzline\Component\ApacheServerStatusParser\Service\Builder\LocalStorageBuilder();

$parserBuilder = $parserBuilderFactory->create();
$parserBuilder = $parserBuilderFactory->create();
//end of dependencies

//begin of business logic
Expand All @@ -66,7 +66,7 @@ function dumpSectionIfThereIsSomeContent(array $lines = null, $name)
$storageBuilder->selectParseModeDetailOnlyUpfront();
$storageBuilder->build();

$listOfNameToElapsedTime['fetching'] = PHP_Timer::secondsToTimeString(
$listOfNameToElapsedTime['fetching'] = PHP_Timer::secondsToTimeString(
PHP_Timer::stop()
);

Expand Down
8 changes: 4 additions & 4 deletions example/remote/parse_all.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function dumpSectionIfThereIsSomeContent(array $lines = null, $name)
: 'http://testdata.bazzline.net/apache_server_status/index.html'
);

$parserBuilder = $parserBuilderFactory->create();
$parserBuilder = $parserBuilderFactory->create();
//end of dependencies

//begin of business logic
Expand All @@ -66,11 +66,11 @@ function dumpSectionIfThereIsSomeContent(array $lines = null, $name)
$storageBuilder->selectParseModeAllUpfront();
$storageBuilder->build();

$listOfNameToElapsedTime['fetching'] = PHP_Timer::secondsToTimeString(
$listOfNameToElapsedTime['fetching'] = PHP_Timer::secondsToTimeString(
PHP_Timer::stop()
);

$storage = $storageBuilder->andGetStorageAfterTheBuild();
$storage = $storageBuilder->andGetStorageAfterTheBuild();

dumpSectionIfThereIsSomeContent($storage->getListOfInformation(), 'Information');
dumpSectionIfThereIsSomeContent($storage->getListOfDetail(), 'Detail');
Expand All @@ -82,7 +82,7 @@ function dumpSectionIfThereIsSomeContent(array $lines = null, $name)
$parserBuilder->setStorageUpfront($storage);
$parserBuilder->build();

$listOfNameToElapsedTime['parsing'] = PHP_Timer::secondsToTimeString(
$listOfNameToElapsedTime['parsing'] = PHP_Timer::secondsToTimeString(
PHP_Timer::stop()
);

Expand Down
4 changes: 2 additions & 2 deletions example/remote/parse_detail_only.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function dumpSectionIfThereIsSomeContent(array $lines = null, $name)
: 'http://testdata.bazzline.net/apache_server_status/index.html'
);

$parserBuilder = $parserBuilderFactory->create();
$parserBuilder = $parserBuilderFactory->create();
//end of dependencies

//begin of business logic
Expand All @@ -66,7 +66,7 @@ function dumpSectionIfThereIsSomeContent(array $lines = null, $name)
$storageBuilder->selectParseModeDetailOnlyUpfront();
$storageBuilder->build();

$listOfNameToElapsedTime['fetching'] = PHP_Timer::secondsToTimeString(
$listOfNameToElapsedTime['fetching'] = PHP_Timer::secondsToTimeString(
PHP_Timer::stop()
);

Expand Down
2 changes: 1 addition & 1 deletion source/Service/Content/Fetcher/AbstractFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function fetch()

$lines = array_filter(
$contentAsArray,
function ($item) {
function($item) {
return (strlen(trim($item)) > 0);
}
);
Expand Down
7 changes: 5 additions & 2 deletions source/Service/Content/Fetcher/HttpFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function __construct(
*/
public function setUrl($url)
{
$this->url = $url;
$this->url = $url;
}


Expand Down Expand Up @@ -74,7 +74,10 @@ protected function fetchContentAsStringOrThrowRuntimeException()
self::STATUS_CODE_HIGHER_THAN_ALLOWED_EXCEPTION_MESSAGE,
$response->statusCode(),
$highestAllowedStatusCode,
implode(', ' , $response->convertIntoAnArray())
implode(
', ',
$response->convertIntoAnArray()
)
)
);
}
Expand Down
2 changes: 1 addition & 1 deletion source/Service/Content/Parser/DetailLineParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function parse($line)
'',
(isset($lineAsArray[19]) ? $lineAsArray[19] : $lineAsArray[18])
);
$uriPathWithQuery = (
$uriPathWithQuery = (
$stringUtility->endsWith($lineAsArray[17], '}')
? substr($lineAsArray[17], 0, -1)
: $lineAsArray[17]
Expand Down
4 changes: 2 additions & 2 deletions source/Service/Content/Parser/InformationListOfLineParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class InformationListOfLineParser implements ListOfLineParserInterface
public function __construct(
StringUtility $stringUtility
) {
$this->stringUtility = $stringUtility;
$this->stringUtility = $stringUtility;
}

/**
Expand Down Expand Up @@ -63,7 +63,7 @@ public function parse(array $listOfLine)
//stop repeating yourself, us the $listOfMandatoryPropertyNameToStartsWithPrefix
//take a look to the StatisticListOfLineParser
if ($stringUtility->startsWith($line, 'Apache Server Status for ')) {
$listOMandatoryProperties['identifier'] = substr($line, 25); //always use numbers if you are dealing with static strings
$listOMandatoryProperties['identifier'] = substr($line, 25); //always use numbers if you are dealing with static strings
} else if ($stringUtility->startsWith($line, 'Server Version: ')) {
$listOMandatoryProperties['version'] = substr($line, 16);
} else if ($stringUtility->startsWith($line, 'Server MPM: ')) {
Expand Down
19 changes: 9 additions & 10 deletions source/Service/Content/Parser/StatisticListOfLineParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ public function __construct(
public function parse(array $listOfLine)
{
//begin of dependencies
$stringUtility = $this->stringUtility;
$stringUtility = $this->stringUtility;
//end of dependencies

//begin of business logic
$listOfLineHasMinimalSize = (count($listOfLine) > 9);

if ($listOfLineHasMinimalSize) {
$listOfMandatoryPropertyNameToStartsWithPrefix = [
$listOfMandatoryPropertyNameToStartsWithPrefix = [
'current_timestamp' => 'Current Time: ',
'cpu_usage' => 'CPU Usage: ',
'parent_server_configuration_generation' => 'Parent Server Config. Generation: ',
Expand All @@ -60,8 +60,7 @@ public function parse(array $listOfLine)
Total accesses: : 16
Total Traffic: : 15
*/

$listOMandatoryProperties = [
$listOMandatoryProperties = [
'b_per_seconds' => null,
'current_time' => null,
'cpu_load' => null,
Expand Down Expand Up @@ -105,33 +104,33 @@ public function parse(array $listOfLine)
} else if ($stringUtility->startsWith($line, $listOfMandatoryPropertyNameToStartsWithPrefix['server_load'])) {
$listOMandatoryProperties['server_load'] = substr($line, 13);
} else if ($stringUtility->startsWith($line, $listOfMandatoryPropertyNameToStartsWithPrefix['total_accesses'])) {
$lineAsArray = explode(' - ', $line);
$lineAsArray = explode(' - ', $line);

$listOMandatoryProperties['total_accesses'] = substr($lineAsArray[0], 16);
$listOMandatoryProperties['total_traffic'] = substr($lineAsArray[1], 15);
} else if ($stringUtility->endsWith($line, 'request')) {
$lineAsArray = explode(' - ', $line);

$listOMandatoryProperties['b_per_seconds'] = filter_var(
$listOMandatoryProperties['b_per_seconds'] = filter_var(
$lineAsArray[1],
FILTER_SANITIZE_NUMBER_INT
);
$listOMandatoryProperties['kb_per_seconds'] = filter_var(
$listOMandatoryProperties['kb_per_seconds'] = filter_var(
$lineAsArray[2],
FILTER_SANITIZE_NUMBER_INT
);
$listOMandatoryProperties['request_per_seconds'] = filter_var(
$listOMandatoryProperties['request_per_seconds'] = filter_var(
$lineAsArray[0],
FILTER_SANITIZE_NUMBER_INT
);
} else if ($stringUtility->endsWith($line, 'workers')) {
$lineAsArray = explode(',', $line);

$listOMandatoryProperties['idle_workers'] = filter_var(
$listOMandatoryProperties['idle_workers'] = filter_var(
$lineAsArray[1],
FILTER_SANITIZE_NUMBER_INT
);
$listOMandatoryProperties['request_currently_being_processed'] = filter_var(
$listOMandatoryProperties['request_currently_being_processed'] = filter_var(
$lineAsArray[0],
FILTER_SANITIZE_NUMBER_INT
);
Expand Down

0 comments on commit 5fb3197

Please sign in to comment.