Completed
Pull Request — master (#79)
by ARCANEDEV
04:20
created

NoCaptchaManager   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 58
rs 10
c 0
b 0
f 0
ccs 14
cts 14
cp 1
wmc 6
lcom 1
cbo 3

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getDefaultDriver() 0 4 1
A version() 0 4 1
A createV2Driver() 0 8 2
A createV3Driver() 0 8 2
1
<?php namespace Arcanedev\NoCaptcha;
2
3
use Illuminate\Support\Manager;
4
use Arcanedev\NoCaptcha\Contracts\NoCaptchaManager as NoCaptchaManagerContract;
5
6
/**
7
 * Class     NoCaptchaManager
8
 *
9
 * @package  Arcanedev\NoCaptcha
10
 * @author   ARCANEDEV <[email protected]>
11
 */
12
class NoCaptchaManager extends Manager implements NoCaptchaManagerContract
13
{
14
    /* -----------------------------------------------------------------
15
     |  Getters
16
     | -----------------------------------------------------------------
17
     */
18
19
    /**
20
     * Get the default driver name.
21
     *
22
     * @return string
23
     */
24 4
    public function getDefaultDriver()
25
    {
26 4
        return config('no-captcha.version');
27
    }
28
29
    /* -----------------------------------------------------------------
30
     |  Main Methods
31
     | -----------------------------------------------------------------
32
     */
33
34
    /**
35
     * Get the NoCaptcha driver by the given version.
36
     *
37
     * @param  string|null  $version
38
     *
39
     * @return \Arcanedev\NoCaptcha\NoCaptchaV3|\Arcanedev\NoCaptcha\NoCaptchaV2
40
     */
41 20
    public function version($version = null)
42
    {
43 20
        return $this->driver($version);
44
    }
45
46
    /**
47
     * @return \Arcanedev\NoCaptcha\NoCaptchaV3
48
     */
49 4
    public function createV2Driver()
50
    {
51 4
        return new NoCaptchaV3(
52 4
            config('no-captcha.secret'),
53 4
            config('no-captcha.sitekey'),
54 4
            config('no-captcha.lang') ?: $this->app->getLocale()
55
        );
56
    }
57
58
    /**
59
     * @return \Arcanedev\NoCaptcha\NoCaptchaV3
60
     */
61 20
    public function createV3Driver()
62
    {
63 20
        return new NoCaptchaV3(
64 20
            config('no-captcha.secret'),
65 20
            config('no-captcha.sitekey'),
66 20
            config('no-captcha.lang') ?: $this->app->getLocale()
67
        );
68
    }
69
}
70