Skip to content

Commit

Permalink
Use RequiredParameterTrait
Browse files Browse the repository at this point in the history
  • Loading branch information
richardhj committed Oct 12, 2016
1 parent cfb5423 commit 7aa4ce8
Showing 1 changed file with 5 additions and 21 deletions.
26 changes: 5 additions & 21 deletions src/Provider/EPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use League\OAuth2\Client\Provider\AbstractProvider;
use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
use League\OAuth2\Client\Token\AccessToken;
use League\OAuth2\Client\Tool\RequiredParameterTrait;
use Psr\Http\Message\ResponseInterface;


Expand All @@ -23,6 +24,9 @@
class EPost extends AbstractProvider
{

use RequiredParameterTrait;


/**
* The login endpoint for production
*
Expand Down Expand Up @@ -68,7 +72,7 @@ class EPost extends AbstractProvider
*/
public function __construct(array $options = [], array $collaborators = [])
{
$this->assertRequiredOptions($options);
$this->checkRequiredParameters($this->getRequiredOptions(), $options);

$possible = $this->getConfigurableOptions();
$configured = array_intersect_key($options, array_flip($possible));
Expand Down Expand Up @@ -210,24 +214,4 @@ protected function getRequiredOptions()
'scopes',
];
}


/**
* Verifies that all required options have been passed
*
* @param array $options
*
* @return void
* @throws \InvalidArgumentException
*/
protected function assertRequiredOptions(array $options)
{
$missing = array_diff_key(array_flip($this->getRequiredOptions()), $options);

if (!empty($missing)) {
throw new \InvalidArgumentException(
'Required options not defined: '.implode(', ', array_keys($missing))
);
}
}
}

0 comments on commit 7aa4ce8

Please sign in to comment.