Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
yajra authored and StyleCIBot committed Oct 28, 2017
1 parent d0ab99a commit 226acc8
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 48 deletions.
16 changes: 10 additions & 6 deletions src/yajra/Zillow/Facade.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
<?php namespace yajra\Zillow;
<?php

use Illuminate\Support\Facades\Facade as IlluminateFacade;
namespace yajra\Zillow;

class Facade extends IlluminateFacade {
use Illuminate\Support\Facades\Facade as IlluminateFacade;

class Facade extends IlluminateFacade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor() { return 'zillow'; }

}
protected static function getFacadeAccessor()
{
return 'zillow';
}
}
9 changes: 5 additions & 4 deletions src/yajra/Zillow/ServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php namespace yajra\Zillow;
<?php

namespace yajra\Zillow;

use Illuminate\Support\ServiceProvider as IlluminateServiceProvider;
use yajra\Zillow\ZillowClient;
use Config;
use Illuminate\Support\ServiceProvider as IlluminateServiceProvider;

class ServiceProvider extends IlluminateServiceProvider
{
Expand Down Expand Up @@ -47,6 +48,6 @@ public function register()
*/
public function provides()
{
return array('zillow');
return ['zillow'];
}
}
50 changes: 26 additions & 24 deletions src/yajra/Zillow/ZillowClient.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?php namespace yajra\Zillow;
<?php

namespace yajra\Zillow;

use GuzzleHttp\Client as GuzzleClient;
use Goutte\Client as GoutteClient;
use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\ClientInterface as GuzzleClientInterface;
use yajra\Zillow\ZillowException;

/**
* Client
* Client.
*
* @author Arjay Angeles <aqangeles@gmail.com>
*/
Expand Down Expand Up @@ -82,7 +83,7 @@ class ZillowClient
];

/**
* Initiate the class
* Initiate the class.
* @param string $ZWSID
* @return object
*/
Expand All @@ -93,7 +94,7 @@ public function __construct($ZWSID)

/**
* Set client
* return GuzzleClient
* return GuzzleClient.
*/
public function setClient(GuzzleClientInterface $client)
{
Expand All @@ -104,12 +105,12 @@ public function setClient(GuzzleClientInterface $client)

/**
* get GuzzleClient, create if it's null
* return GuzzleClient
* return GuzzleClient.
*/
public function getClient()
{
if (!$this->client) {
$this->client = new GuzzleClient(array('defaults' => array('allow_redirects' => true, 'cookies' => true)));
if (! $this->client) {
$this->client = new GuzzleClient(['defaults' => ['allow_redirects' => true, 'cookies' => true]]);
}

return $this->client;
Expand All @@ -120,7 +121,7 @@ public function getClient()
*/
public function setZWSID($id)
{
return ($this->ZWSID = $id);
return $this->ZWSID = $id;
}

/**
Expand All @@ -132,7 +133,7 @@ public function getZWSID()
}

/**
* Check if the last request was successful
* Check if the last request was successful.
* @return bool
*/
public function isSuccessful()
Expand All @@ -141,7 +142,7 @@ public function isSuccessful()
}

/**
* return the status code from the last call
* return the status code from the last call.
* @return int
*/
public function getStatusCode()
Expand All @@ -150,7 +151,7 @@ public function getStatusCode()
}

/**
* return the status message from the last call
* return the status message from the last call.
* @return string
*/
public function getStatusMessage()
Expand All @@ -159,7 +160,7 @@ public function getStatusMessage()
}

/**
* return the actual response array from the last call
* return the actual response array from the last call.
* @return array
*/
public function getResponse()
Expand All @@ -168,7 +169,7 @@ public function getResponse()
}

/**
* return the results array from the GetSearchResults call
* return the results array from the GetSearchResults call.
* @return array
*/
public function getResults()
Expand All @@ -178,7 +179,7 @@ public function getResults()

/**
* magic method to invoke the correct API call
* if the passed name is within the valid callbacks
* if the passed name is within the valid callbacks.
* @param string $name
* @param array $arguments
* @return array
Expand All @@ -193,7 +194,7 @@ public function __call($name, $arguments)
/**
* Since zillow does not provide the ability to grab the photos
* of the properties through the API this little method will scan
* the property url and grab all the images for that property
* the property url and grab all the images for that property.
* @param string $uri
* @return array
*/
Expand All @@ -217,7 +218,7 @@ public function getPhotos($uri)
* see @GetPhotos
* Works the same way but instead passing a uri
* you can pass a zpid and it will perform a request to grab the uri
* based on the id
* based on the id.
* @see GetPhotos
* @param int @zpid
* @return array
Expand All @@ -238,7 +239,7 @@ public function getPhotosById($zpid)
}

/**
* set the statis code and message of the api call
* set the statis code and message of the api call.
* @param int $code
* @param string $message
* @return void
Expand All @@ -250,16 +251,16 @@ protected function setStatus($code, $message)
}

/**
* Perform the actual request to the zillow api endpoint
* Perform the actual request to the zillow api endpoint.
* @param string $name
* @param array $params
* @return array
*/
protected function doRequest($call, array $params)
{
// Validate
if (!$this->getZWSID()) {
throw new ZillowException("You must submit the ZWSID");
if (! $this->getZWSID()) {
throw new ZillowException('You must submit the ZWSID');
}

// Run the call
Expand All @@ -273,7 +274,7 @@ protected function doRequest($call, array $params)

/**
* Parse the reponse into a formatted array
* also set the status code and status message
* also set the status code and status message.
* @param object $response
* @return array
*/
Expand All @@ -282,8 +283,9 @@ protected function parseResponse($response)
// Init
$this->response = json_decode(json_encode($response), true);

if (!$this->response['message']) {
if (! $this->response['message']) {
$this->setStatus(999, 'XML WAS NOT FOUND');

return;
}

Expand Down
10 changes: 7 additions & 3 deletions src/yajra/Zillow/ZillowException.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<?php namespace yajra\Zillow;
<?php

namespace yajra\Zillow;

use Exception;

/**
* Default exception class
* Default exception class.
*/
class ZillowException extends Exception {}
class ZillowException extends Exception
{
}
2 changes: 1 addition & 1 deletion src/yajra/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

return [

/**
/*
* Zillow Web Services ID (ZWSID)
*
* http://www.zillow.com/webservice/Registration.htm
Expand Down
18 changes: 8 additions & 10 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,15 @@

namespace Zillow\Tests;

use GuzzleHttp\Stream\Stream;
use yajra\Zillow\ZillowClient;
use GuzzleHttp\Subscriber\Mock;
use GuzzleHttp\Subscriber\History;
use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Message\Response as GuzzleResponse;
use GuzzleHttp\Stream\Stream;
use GuzzleHttp\Subscriber\History;
use GuzzleHttp\Subscriber\Mock;
use GuzzleHttp\Post\PostFile;

/**
* Goutte Client Test
* Goutte Client Test.
*
* @author Arjay Angeles <aqangeles@gmail.com>
*/
Expand All @@ -33,9 +31,9 @@ class ClientTest extends \PHPUnit_Framework_TestCase
protected function getGuzzle()
{
$this->history = new History();
$this->mock = new Mock();
$this->mock->addResponse(new GuzzleResponse(200, array(), Stream::factory('<html><body><p>Hi</p></body></html>')));
$guzzle = new GuzzleClient(array('redirect.disable' => true, 'base_url' => ''));
$this->mock = new Mock();
$this->mock->addResponse(new GuzzleResponse(200, [], Stream::factory('<html><body><p>Hi</p></body></html>')));
$guzzle = new GuzzleClient(['redirect.disable' => true, 'base_url' => '']);
$guzzle->getEmitter()->attach($this->mock);
$guzzle->getEmitter()->attach($this->history);

Expand All @@ -58,7 +56,7 @@ public function testUsesCustomClient()

public function testZWSID()
{
$client = new ZillowClient('xxxxx');
$client = new ZillowClient('xxxxx');
$this->assertSame('xxxxx', $client->getZWSID());
}
}

0 comments on commit 226acc8

Please sign in to comment.