for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* @author Dmitry Gladyshev <[email protected]>
*/
namespace Rucaptcha;
use Rucaptcha\Exception\InvalidArgumentException;
trait ConfigurableTrait
{
* @param array $options
* @param bool $ignoreMissingOptions
* @throws InvalidArgumentException
public function setOptions(array $options, $ignoreMissingOptions = false)
foreach ($options as $option => $value) {
$setter = 'set' . ucfirst($option);
if (method_exists($this, $setter)) {
$this->$setter($value);
continue;
}
if (property_exists($this, $option)) {
$this->$option = $value;
if (!$ignoreMissingOptions) {
throw new InvalidArgumentException("Property `{$option}` not found in class `" . __CLASS__ . "`.");