Lines
100.00%
30 / 30
Methods
100.00%
12 / 12
Classes
100.00%
1 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| renderCaptcha | 100.00% | 13 / 13 | 100.00% | 1 / 1 | 3 | ||
| [phpMyFAQ\Helper\AbstractHelper] setCategory | 100.00% | 2 / 2 | 100.00% | 1 / 1 | 1 | ||
| [phpMyFAQ\Helper\AbstractHelper] getCategory | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| [phpMyFAQ\Helper\AbstractHelper] category | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| [phpMyFAQ\Helper\AbstractHelper] plurals | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| [phpMyFAQ\Helper\AbstractHelper] setCategoryRelation | 100.00% | 2 / 2 | 100.00% | 1 / 1 | 1 | ||
| [phpMyFAQ\Helper\AbstractHelper] setTags | 100.00% | 2 / 2 | 100.00% | 1 / 1 | 1 | ||
| [phpMyFAQ\Helper\AbstractHelper] setPlurals | 100.00% | 2 / 2 | 100.00% | 1 / 1 | 1 | ||
| [phpMyFAQ\Helper\AbstractHelper] setSessionId | 100.00% | 2 / 2 | 100.00% | 1 / 1 | 1 | ||
| [phpMyFAQ\Helper\AbstractHelper] setConfiguration | 100.00% | 2 / 2 | 100.00% | 1 / 1 | 1 | ||
| [phpMyFAQ\Helper\AbstractHelper] getConfiguration | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| 26 | class GoogleRecaptchaAbstractHelper extends AbstractHelper implements CaptchaHelperInterface | |
| 27 | { | |
| 28 | /** | |
| 29 | * Constructor. | |
| 30 | */ | |
| 31 | public function __construct( | |
| 32 | protected Configuration $configuration, | |
| 33 | ) { | |
| 34 | } | |
| 35 | ||
| 36 | public function renderCaptcha( | |
| 37 | CaptchaInterface $captcha, | |
| 38 | string $action = '', | |
| 39 | string $label = '', | |
| 40 | bool $auth = false, | |
| 41 | ): string { | |
| 42 | $html = ''; | |
| 43 | ||
| 44 | if (true === $this->configuration->get(item: 'spam.enableCaptchaCode') && !$auth) { | |
| 45 | $html .= '<div class="row mb-2">'; | |
| 46 | $html .= sprintf('<label class="col-sm-3 col-form-label">%s</label>', $label); | |
| 47 | $html .= ' <div class="col-sm-9">'; | |
| 48 | $html .= ' <script src="https://www.google.com/recaptcha/api.js" async defer></script>'; | |
| 49 | $html .= sprintf( | |
| 50 | '<div class="g-recaptcha" data-sitekey="%s"></div>', | |
| 51 | (string) $this->configuration->get(item: 'security.googleReCaptchaV2SiteKey'), | |
| 52 | ); | |
| 53 | $html .= ' </div>'; | |
| 54 | $html .= '</div>'; | |
| 55 | } | |
| 56 | ||
| 57 | return $html; | |
| 58 | } | |
| 59 | } |
Inherited from phpMyFAQ\Helper\AbstractHelper
| 47 | public function setCategory(Category $Category): AbstractHelper | |
| 48 | { | |
| 49 | $this->Category = $Category; | |
| 50 | return $this; | |
| 51 | } |
| 53 | public function getCategory(): Category | |
| 54 | { | |
| 55 | return $this->category(); | |
| 56 | } |
| 61 | protected function category(): Category | |
| 62 | { | |
| 63 | return $this->Category ?? throw new \LogicException('setCategory() must be called before use.'); | |
| 64 | } |
| 69 | protected function plurals(): Plurals | |
| 70 | { | |
| 71 | return $this->plurals ?? throw new \LogicException('setPlurals() must be called before use.'); | |
| 72 | } |
| 74 | public function setCategoryRelation(Relation $categoryRelation): AbstractHelper | |
| 75 | { | |
| 76 | $this->categoryRelation = $categoryRelation; | |
| 77 | return $this; | |
| 78 | } |
| 80 | public function setTags(Tags $Tags): AbstractHelper | |
| 81 | { | |
| 82 | $this->Tags = $Tags; | |
| 83 | return $this; | |
| 84 | } |
| 86 | public function setPlurals(Plurals $plurals): AbstractHelper | |
| 87 | { | |
| 88 | $this->plurals = $plurals; | |
| 89 | return $this; | |
| 90 | } |
| 92 | public function setSessionId(int|string $sid): AbstractHelper | |
| 93 | { | |
| 94 | $this->sessionId = $sid; | |
| 95 | return $this; | |
| 96 | } |
| 98 | public function setConfiguration(Configuration $configuration): AbstractHelper | |
| 99 | { | |
| 100 | $this->configuration = $configuration; | |
| 101 | return $this; | |
| 102 | } |
| 104 | public function getConfiguration(): Configuration | |
| 105 | { | |
| 106 | return $this->configuration; | |
| 107 | } |