| 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 |
/** |
| 18 |
* Provides support for blacklisting explicit properties from the |
| 19 |
* mass assignment behavior. |
| 20 |
*/ |
| 21 |
trait GuardedPropertyTrait |
| 22 |
{ |
| 23 |
/** |
| 24 |
* The properties that aren't mass assignable. |
| 25 |
* |
| 26 |
* @var array |
| 27 |
*/ |
| 28 |
protected $guarded = []; |
| 29 |
/** |
| 30 |
* Attempts to mass assign the given options to explicitly defined properties, |
| 31 |
* skipping over any properties that are defined in the guarded array. |
| 32 |
* |
| 33 |
* @param array $options |
| 34 |
* @return mixed |
| 35 |
*/ |
| 36 |
protected function fillProperties(array $options = []) |
| 37 |
{ |
| 38 |
if (isset($options['guarded'])) { |
| 39 |
unset($options['guarded']); |
| 40 |
} |
| 41 |
foreach ($options as $option => $value) { |
| 42 |
if (\property_exists($this, $option) && !$this->isGuarded($option)) { |
| 43 |
$this->{$option} = $value; |
| 44 |
} |
| 45 |
} |
| 46 |
} |
| 47 |
/** |
| 48 |
* Returns current guarded properties. |
| 49 |
* |
| 50 |
* @return array |
| 51 |
*/ |
| 52 |
public function getGuarded() |
| 53 |
{ |
| 54 |
return $this->guarded; |
| 55 |
} |
| 56 |
/** |
| 57 |
* Determines if the given property is guarded. |
| 58 |
* |
| 59 |
* @param string $property |
| 60 |
* @return bool |
| 61 |
*/ |
| 62 |
public function isGuarded($property) |
| 63 |
{ |
| 64 |
return \in_array($property, $this->getGuarded()); |
| 65 |
} |
| 66 |
} |
| 67 |
|