Completed
Push — develop ( edb8bf...6f43a0 )
by Nate
08:26
created

FacebookSettings::rules()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 30

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 30
rs 9.44
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://flipboxfactory.com/software/patron/license
6
 * @link       https://www.flipboxfactory.com/software/patron/
7
 */
8
9
namespace flipbox\patron\settings;
10
11
use Craft;
12
use flipbox\craft\ember\helpers\ModelHelper;
13
use League\OAuth2\Client\Provider\Facebook;
14
15
/**
16
 * @author Flipbox Factory <[email protected]>
17
 * @since 1.0.0
18
 */
19
class FacebookSettings extends BaseSettings
20
{
21
    /**
22
     * @var string
23
     */
24
    public $graphApiVersion = 'v2.10';
25
26
    /**
27
     * @return string
28
     * @throws \Twig_Error_Loader
29
     * @throws \yii\base\Exception
30
     */
31
    public function inputHtml(): string
32
    {
33
        return Craft::$app->getView()->renderTemplate(
34
            'patron/_settings/facebook',
35
            [
36
                'settings' => $this
37
            ]
38
        );
39
    }
40
41
    /**
42
     * @inheritdoc
43
     */
44
    public function rules()
45
    {
46
        return array_merge(
47
            parent::rules(),
48
            [
49
                [
50
                    [
51
                        'graphApiVersion'
52
                    ],
53
                    'match',
54
                    'pattern' => Facebook::GRAPH_API_VERSION_REGEX
55
                ],
56
                [
57
                    [
58
                        'graphApiVersion'
59
                    ],
60
                    'required'
61
                ],
62
                [
63
                    [
64
                        'graphApiVersion'
65
                    ],
66
                    'safe',
67
                    'on' => [
68
                        ModelHelper::SCENARIO_DEFAULT
69
                    ]
70
                ]
71
            ]
72
        );
73
    }
74
}
75