| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* This file is part of the league/oauth2-client library |
| 5 |
* |
| 6 |
* For the full copyright and license information, please view the LICENSE |
| 7 |
* file that was distributed with this source code. |
| 8 |
* |
| 9 |
* @copyright Copyright (c) Alex Bilbie <hello@alexbilbie.com> |
| 10 |
* @license http://opensource.org/licenses/MIT MIT |
| 11 |
* @link http://thephpleague.com/oauth2-client/ Documentation |
| 12 |
* @link https://packagist.org/packages/league/oauth2-client Packagist |
| 13 |
* @link https://github.com/thephpleague/oauth2-client GitHub |
| 14 |
*/ |
| 15 |
namespace YoastSEO_Vendor\League\OAuth2\Client\Tool; |
| 16 |
|
| 17 |
use BadMethodCallException; |
| 18 |
/** |
| 19 |
* Provides functionality to check for required parameters. |
| 20 |
*/ |
| 21 |
trait RequiredParameterTrait |
| 22 |
{ |
| 23 |
/** |
| 24 |
* Checks for a required parameter in a hash. |
| 25 |
* |
| 26 |
* @throws BadMethodCallException |
| 27 |
* @param string $name |
| 28 |
* @param array $params |
| 29 |
* @return void |
| 30 |
*/ |
| 31 |
private function checkRequiredParameter($name, array $params) |
| 32 |
{ |
| 33 |
if (!isset($params[$name])) { |
| 34 |
throw new \BadMethodCallException(\sprintf('Required parameter not passed: "%s"', $name)); |
| 35 |
} |
| 36 |
} |
| 37 |
/** |
| 38 |
* Checks for multiple required parameters in a hash. |
| 39 |
* |
| 40 |
* @throws InvalidArgumentException |
| 41 |
* @param array $names |
| 42 |
* @param array $params |
| 43 |
* @return void |
| 44 |
*/ |
| 45 |
private function checkRequiredParameters(array $names, array $params) |
| 46 |
{ |
| 47 |
foreach ($names as $name) { |
| 48 |
$this->checkRequiredParameter($name, $params); |
| 49 |
} |
| 50 |
} |
| 51 |
} |
| 52 |
|