Skip to content

Commit

Permalink
psr-fixes, 0.2.2 release
Browse files Browse the repository at this point in the history
  • Loading branch information
dsentker committed Dec 6, 2017
1 parent 1985efb commit 5d8252f
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 13 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ An easy-to-use API Wrapper for [Googles PageSpeed Insights](https://developers.g

### Simple Usage
```php
$uri = 'http://example.com';
$url = 'http://example.com';

$caller = new \PhpInsights\InsightsCaller('your-google-api-key-here', 'de');
$response = $caller->getResponse($uri, \PhpInsights\InsightsCaller::STRATEGY_MOBILE);
$response = $caller->getResponse($url, \PhpInsights\InsightsCaller::STRATEGY_MOBILE);
$result = $response->getMappedResult();

var_dump($result->getSpeedScore()); // 100
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "dsentker/phpinsights",
"description": "A php wrapper for Googles page speed insights",
"version": "0.2.2",
"require": {
"php": "^5.4 || ^7.0",
"netresearch/jsonmapper": "^1.1",
Expand Down
1 change: 1 addition & 0 deletions src/InsightsCaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public function setCaptureScreenshot($captureScreenshot)
protected function createApiEndpointUrl($url, $strategy = 'mobile')
{
$screenshot = ($this->isCaptureScreenshot()) ? 'true' : 'false';

return sprintf(self::GI_API_ENDPOINT, $url, $strategy, $this->apiKey, $this->locale, $screenshot);
}

Expand Down
3 changes: 2 additions & 1 deletion src/InsightsResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ private function __construct($jsonResponse)
*
* @throws InvalidJsonException
*/
public static function validateResponse($json) {
public static function validateResponse($json)
{

$result = json_decode($json);

Expand Down
1 change: 0 additions & 1 deletion src/Result/InsightsException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

namespace PhpInsights\Result;

class InsightsException extends \Exception
Expand Down
8 changes: 5 additions & 3 deletions src/Result/InsightsResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

class InsightsResult
{

/** @var string */
private $kind;

Expand Down Expand Up @@ -149,7 +150,7 @@ public function getUsabilityScore()
{
$ruleGroups = $this->getRuleGroups();

if(!array_key_exists(RuleGroup::GROUP_USABILITY, $ruleGroups)) {
if (!array_key_exists(RuleGroup::GROUP_USABILITY, $ruleGroups)) {
throw new UsabilityScoreNotAvailableException('Usability score is only available with mobile strategy API call.');
}

Expand All @@ -162,6 +163,7 @@ public function getUsabilityScore()
public function getSpeedScore()
{
$ruleGroups = $this->getRuleGroups();

return $ruleGroups[RuleGroup::GROUP_SPEED]->getScore();

}
Expand All @@ -182,8 +184,8 @@ public function hasScreenshot()
public function getScreenshot()
{

if(!$this->hasScreenshot()) {
ScreenshotNotAvailableException::raise();
if (!$this->hasScreenshot()) {
ScreenshotNotAvailableException::raise();
}

return $this->screenshot;
Expand Down
1 change: 0 additions & 1 deletion src/Result/InsightsResultException.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php
namespace PhpInsights\Result;


class InsightsResultException extends \Exception
{

Expand Down
4 changes: 2 additions & 2 deletions src/Result/Map/FormattedResults.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public function setRuleResults($ruleResults)
public function getRuleResultsByGroup($group)
{
$results = [];
foreach($this->getRuleResults() as $rule => $ruleResult) {
if(in_array($group, $ruleResult->getGroups())) {
foreach ($this->getRuleResults() as $rule => $ruleResult) {
if (in_array($group, $ruleResult->getGroups())) {
$results[$rule] = $ruleResult;
}
}
Expand Down
1 change: 0 additions & 1 deletion src/Result/Map/Screenshot.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php
namespace PhpInsights\Result\Map;


class Screenshot
{

Expand Down
1 change: 0 additions & 1 deletion src/Result/ScreenshotNotAvailableException.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php
namespace PhpInsights\Result;


class ScreenshotNotAvailableException extends InsightsResultException
{

Expand Down
1 change: 0 additions & 1 deletion src/Result/UsabilityScoreNotAvailableException.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php
namespace PhpInsights\Result;


class UsabilityScoreNotAvailableException extends InsightsResultException
{

Expand Down

0 comments on commit 5d8252f

Please sign in to comment.