From 7aa4ce82dd4e894f276cf5c15885900eb517ab2d Mon Sep 17 00:00:00 2001 From: Richard Henkenjohann Date: Wed, 12 Oct 2016 19:35:52 +0200 Subject: [PATCH] Use RequiredParameterTrait --- src/Provider/EPost.php | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/src/Provider/EPost.php b/src/Provider/EPost.php index 1d1842d..f89a011 100644 --- a/src/Provider/EPost.php +++ b/src/Provider/EPost.php @@ -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; @@ -23,6 +24,9 @@ class EPost extends AbstractProvider { + use RequiredParameterTrait; + + /** * The login endpoint for production * @@ -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)); @@ -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)) - ); - } - } }