| 1 | <?php |
||||||
| 2 | |||||||
| 3 | namespace ByTIC\GoogleRecaptcha\Manager\Traits; |
||||||
| 4 | |||||||
| 5 | use ByTIC\GoogleRecaptcha\Config\Config; |
||||||
| 6 | |||||||
| 7 | /** |
||||||
| 8 | * Trait HasConfigTrait |
||||||
| 9 | * @package ByTIC\GoogleRecaptcha\Manager\Traits |
||||||
| 10 | */ |
||||||
| 11 | trait HasConfigTrait |
||||||
| 12 | { |
||||||
| 13 | /** |
||||||
| 14 | * @var Config |
||||||
| 15 | */ |
||||||
| 16 | protected $config; |
||||||
| 17 | |||||||
| 18 | /** |
||||||
| 19 | * @param Config $config |
||||||
| 20 | * @return static |
||||||
| 21 | */ |
||||||
| 22 | public static function fromConfig($config) |
||||||
| 23 | { |
||||||
| 24 | $agent = new static(); |
||||||
| 25 | $agent->setConfig($config); |
||||||
| 26 | return $agent; |
||||||
| 27 | } |
||||||
| 28 | |||||||
| 29 | /** |
||||||
| 30 | * @param Config $config |
||||||
| 31 | */ |
||||||
| 32 | public function setConfig($config) |
||||||
| 33 | { |
||||||
| 34 | $this->config = $config; |
||||||
| 35 | $this->populateFromConfig(); |
||||||
| 36 | } |
||||||
| 37 | |||||||
| 38 | protected function populateFromConfig() |
||||||
| 39 | { |
||||||
| 40 | $this->setEnabled($this->config->isEnabled()); |
||||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||||
| 41 | |||||||
| 42 | $site = $this->config->getSiteKey(); |
||||||
| 43 | if ($site) { |
||||||
| 44 | $this->setSiteKey($site); |
||||||
|
0 ignored issues
–
show
It seems like
setSiteKey() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 45 | } |
||||||
| 46 | |||||||
| 47 | $key = $this->config->getSecretKey(); |
||||||
| 48 | if ($key) { |
||||||
| 49 | $this->setSecretKey($key); |
||||||
|
0 ignored issues
–
show
It seems like
setSecretKey() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 50 | } |
||||||
| 51 | } |
||||||
| 52 | } |