CaptchaService   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 2
eloc 5
dl 0
loc 19
rs 10
c 4
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getCaptchaObject() 0 11 2
1
<?php
2
3
namespace WebDevEtc\BlogEtc\Services;
4
5
use WebDevEtc\BlogEtc\Captcha\CaptchaAbstract;
6
use WebDevEtc\BlogEtc\Interfaces\CaptchaInterface;
7
8
/**
9
 * Class CaptchaService.
10
 */
11
class CaptchaService
12
{
13
    /**
14
     * Return either null (if captcha is not enabled), or the captcha object (which should implement
15
     * CaptchaInterface interface / extend the CaptchaAbstract class).
16
     *
17
     * @return CaptchaAbstract|null
18
     */
19
    public function getCaptchaObject(): ?CaptchaInterface
20
    {
21
        if (!config('blogetc.captcha.captcha_enabled')) {
22
            return null;
23
        }
24
25
        // else: captcha is enabled
26
        /** @var string $captchaClass */
27
        $captchaClass = config('blogetc.captcha.captcha_type');
28
29
        return new $captchaClass();
30
    }
31
}
32