Skip to content

Commit

Permalink
Merge pull request #4 from lassodatasystems/remove-oauth2-bundle-chec…
Browse files Browse the repository at this point in the history
…kstyle-violations

Remove Oauth2ClientBundle checkstyle violations
  • Loading branch information
zodeus committed Jul 8, 2014
2 parents 027d2b4 + 075fbb6 commit c64e3f3
Show file tree
Hide file tree
Showing 12 changed files with 112 additions and 24 deletions.
39 changes: 20 additions & 19 deletions Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* Buzz\Browser to get auto-completion on all available methods.
*
* Class Client
*
* @package Lasso\Oauth2ClientBundle
*/
class Client
Expand Down Expand Up @@ -45,7 +46,7 @@ public function __construct(Token $token, Browser $browser)
/**
* Adds authorization token to headers using bearer method
*
* @param $headers
* @param array $headers
*
* @return array
*/
Expand Down Expand Up @@ -75,10 +76,10 @@ protected function throwExceptionOnResponseError(Response $response)
}

/**
* @see Lasso\Oauth2ClientBundle\Client::call
* @param string $url
* @param array $headers
*
* @param $url
* @param array $headers
* @see Lasso\Oauth2ClientBundle\Client::call
*
* @return Response
*/
Expand All @@ -88,12 +89,12 @@ public function get($url, $headers = array())
}

/**
* @see Lasso\Oauth2ClientBundle\Client::call
*
* @param $url
* @param string $url
* @param array $headers
* @param string $content
*
* @see Lasso\Oauth2ClientBundle\Client::call
*
* @return Response
*/
public function post($url, $headers = array(), $content = '')
Expand All @@ -102,10 +103,10 @@ public function post($url, $headers = array(), $content = '')
}

/**
* @see Lasso\Oauth2ClientBundle\Client::call
* @param string $url
* @param array $headers
*
* @param $url
* @param array $headers
* @see Lasso\Oauth2ClientBundle\Client::call
*
* @return Response
*/
Expand All @@ -115,12 +116,12 @@ public function head($url, $headers = array())
}

/**
* @see Lasso\Oauth2ClientBundle\Client::call
*
* @param $url
* @param string $url
* @param array $headers
* @param string $content
*
* @see Lasso\Oauth2ClientBundle\Client::call
*
* @return Response
*/
public function patch($url, $headers = array(), $content = '')
Expand All @@ -129,12 +130,12 @@ public function patch($url, $headers = array(), $content = '')
}

/**
* @see Lasso\Oauth2ClientBundle\Client::call
*
* @param $url
* @param string $url
* @param array $headers
* @param string $content
*
* @see Lasso\Oauth2ClientBundle\Client::call
*
* @return Response
*/
public function put($url, $headers = array(), $content = '')
Expand All @@ -143,12 +144,12 @@ public function put($url, $headers = array(), $content = '')
}

/**
* @see Lasso\Oauth2ClientBundle\Client::call
*
* @param $url
* @param string $url
* @param array $headers
* @param string $content
*
* @see Lasso\Oauth2ClientBundle\Client::call
*
* @return Response
*/
public function delete($url, $headers = array(), $content = '')
Expand Down
27 changes: 27 additions & 0 deletions ClientFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,20 @@
use Lasso\Oauth2ClientBundle\Client;
use Buzz\Browser;

/**
* Class ClientFactory
*
* @package Lasso\Oauth2ClientBundle
*/
class ClientFactory
{
protected $tokenFactory;
protected $browser;

/**
* @param TokenFactory $tokenFactory
* @param Browser $browser
*/
public function __construct(
TokenFactory $tokenFactory,
Browser $browser
Expand All @@ -20,27 +29,45 @@ public function __construct(
$this->browser = $browser;
}

/**
* @param string $clientId
*
* @return $this
*/
public function withClientId($clientId)
{
$this->tokenFactory->withClientId($clientId);

return $this;
}

/**
* @param string $clientSecret
*
* @return $this
*/
public function withClientSecret($clientSecret)
{
$this->tokenFactory->withClientSecret($clientSecret);

return $this;
}

/**
* @param string $tokenUrl
*
* @return $this
*/
public function withTokenUrl($tokenUrl)
{
$this->tokenFactory->withTokenUrl($tokenUrl);

return $this;
}

/**
* Reset
*/
public function reset()
{
$this->tokenFactory->reset();
Expand Down
3 changes: 1 addition & 2 deletions DependencyInjection/LassoOauth2ClientExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ public function load(array $configs, ContainerBuilder $container)
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);

$parameterBag = $container->getParameterBag();
foreach($config as $key => $value) {
foreach ($config as $key => $value) {
$container->setParameter(
'lasso_oauth2.' . $key,
$container->getParameterBag()->resolveValue($value)
Expand Down
6 changes: 5 additions & 1 deletion Exceptions/ClientErrorException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
* Thrown if the response status code is 4xx
*
* Class ClientErrorException
*
* @package Lasso\Oauth2ClientBundle\Exceptions
*/
class ClientErrorException extends HttpStatusCodeException {}
class ClientErrorException extends HttpStatusCodeException
{

}
1 change: 1 addition & 0 deletions Exceptions/HttpStatusCodeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

/**
* Class HttpStatusCodeException
*
* @package Lasso\Oauth2ClientBundle\Exceptions
*/
abstract class HttpStatusCodeException extends Exception
Expand Down
6 changes: 5 additions & 1 deletion Exceptions/ServerErrorException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
* Thrown if response status code is 5xx
*
* Class ServerErrorException
*
* @package Lasso\Oauth2ClientBundle\Exceptions
*/
class ServerErrorException extends HttpStatusCodeException {}
class ServerErrorException extends HttpStatusCodeException
{

}
5 changes: 5 additions & 0 deletions Tests/Unit/ClientFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
use PHPUnit_Framework_TestCase;
use PHPUnit_Framework_MockObject_MockObject;

/**
* Class ClientFactoryTest
*
* @package Lasso\Oauth2ClientBundle\Tests
*/
class ClientFactoryTest extends PHPUnit_Framework_TestCase
{
/**
Expand Down
5 changes: 5 additions & 0 deletions Tests/Unit/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
use Lasso\Oauth2ClientBundle\Exceptions\ServerErrorException;
use PHPUnit_Framework_TestCase;

/**
* Class ClientTest
*
* @package Lasso\Oauth2ClientBundle\Tests\Unit
*/
class ClientTest extends PHPUnit_Framework_TestCase
{
protected $token;
Expand Down
5 changes: 5 additions & 0 deletions Tests/Unit/TokenFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
use PHPUnit_Framework_MockObject_MockObject;
use StdClass;

/**
* Class TokenFactoryTest
*
* @package Lasso\Oauth2ClientBundle\Tests
*/
class TokenFactoryTest extends PHPUnit_Framework_TestCase
{
/**
Expand Down
5 changes: 5 additions & 0 deletions Tests/Unit/TokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

require dirname(__FILE__) . '/../../Token.php';

/**
* Class TokenTest
*
* @package Lasso\Oauth2ClientBundle
*/
class TokenTest extends PHPUnit_Framework_TestCase
{
/**
Expand Down
2 changes: 1 addition & 1 deletion Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

/**
* Class Token
*
* @package Lasso\Oauth2ClientBundle
*/
class Token
Expand Down Expand Up @@ -52,7 +53,6 @@ public function __construct($clientId,
}

/**
*
* @return string
*/
protected function acquireToken()
Expand Down
32 changes: 32 additions & 0 deletions TokenFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
use Buzz\Browser;
use StdClass;

/**
* Class TokenFactory
*
* @package Lasso\Oauth2ClientBundle
*/
class TokenFactory
{
/**
Expand All @@ -24,6 +29,12 @@ class TokenFactory
protected $tokenConfig;
protected $browser;

/**
* @param string $clientId
* @param string $clientSecret
* @param string $tokenUrl
* @param Browser $browser
*/
public function __construct(
$clientId,
$clientSecret,
Expand All @@ -40,32 +51,53 @@ public function __construct(
$this->tokenConfig = clone $this->originalTokenConfig;
}

/**
* @param string $clientId
*
* @return $this
*/
public function withClientId($clientId)
{
$this->tokenConfig->clientId = $clientId;

return $this;
}

/**
* @param string $clientSecret
*
* @return $this
*/
public function withClientSecret($clientSecret)
{
$this->tokenConfig->clientSecret = $clientSecret;

return $this;
}

/**
* @param string $tokenUrl
*
* @return $this
*/
public function withTokenUrl($tokenUrl)
{
$this->tokenConfig->tokenUrl = $tokenUrl;

return $this;
}

/**
* Reset
*/
public function reset()
{
$this->tokenConfig = clone $this->originalTokenConfig;
}

/**
* @return Token
*/
public function create()
{
$token = new Token(
Expand Down

0 comments on commit c64e3f3

Please sign in to comment.