Passed
Push — develop ( 749cf8...d507c0 )
by Andrew
03:42
created

Settings::behaviors()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 11
c 0
b 0
f 0
nc 2
nop 0
dl 0
loc 18
rs 9.9
1
<?php
2
/**
3
 * Disqus plugin for Craft CMS 3.x
4
 *
5
 * Integrates the Disqus commenting system into Craft 3 websites, including
6
 * Single Sign On (SSO) and custom login/logout URLs
7
 *
8
 * @link      https://nystudio107.com
0 ignored issues
show
Coding Style introduced by
The tag in position 1 should be the @copyright tag
Loading history...
9
 * @copyright Copyright (c) 2017 nystudio107
0 ignored issues
show
Coding Style introduced by
@copyright tag must contain a year and the name of the copyright holder
Loading history...
10
 */
0 ignored issues
show
Coding Style introduced by
PHP version not specified
Loading history...
Coding Style introduced by
Missing @category tag in file comment
Loading history...
Coding Style introduced by
Missing @package tag in file comment
Loading history...
Coding Style introduced by
Missing @author tag in file comment
Loading history...
Coding Style introduced by
Missing @license tag in file comment
Loading history...
11
12
namespace nystudio107\disqus\models;
13
14
use nystudio107\disqus\Disqus;
15
16
use Craft;
17
use craft\base\Model;
18
use craft\behaviors\EnvAttributeParserBehavior;
19
20
use yii\behaviors\AttributeTypecastBehavior;
21
22
/**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
23
 * @author    nystudio107
0 ignored issues
show
Coding Style introduced by
The tag in position 1 should be the @package tag
Loading history...
Coding Style introduced by
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
Coding Style introduced by
Tag value for @author tag indented incorrectly; expected 2 spaces but found 4
Loading history...
24
 * @package   Disqus
0 ignored issues
show
Coding Style introduced by
Tag value for @package tag indented incorrectly; expected 1 spaces but found 3
Loading history...
25
 * @since     1.0.0
0 ignored issues
show
Coding Style introduced by
The tag in position 3 should be the @author tag
Loading history...
Coding Style introduced by
Tag value for @since tag indented incorrectly; expected 3 spaces but found 5
Loading history...
26
 */
0 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
27
class Settings extends Model
28
{
29
    // Public Properties
30
    // =========================================================================
31
32
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
33
     * @var string
34
     */
35
    public $disqusShortname = '';
36
37
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
38
     * @var bool
39
     */
40
    public $useSSO = false;
41
42
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
43
     * @var string
44
     */
45
    public $disqusPublicKey = '';
46
47
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
48
     * @var string
49
     */
50
    public $disqusSecretKey = '';
51
52
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
53
     * @var bool
54
     */
55
    public $customLogin = false;
56
57
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
58
     * @var string
59
     */
60
    public $loginName = '';
61
62
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
63
     * @var string
64
     */
65
    public $loginButton = '';
66
67
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
68
     * @var string
69
     */
70
    public $loginIcon = '';
71
72
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
73
     * @var string
74
     */
75
    public $loginUrl = '';
76
77
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
78
     * @var string
79
     */
80
    public $loginLogoutUrl = '';
81
82
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
83
     * @var int
84
     */
85
    public $loginWidth = 800;
86
87
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
88
     * @var int
89
     */
90
    public $loginHeight = 400;
91
92
    // Public Methods
93
    // =========================================================================
94
95
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
96
     * @inheritdoc
97
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
98
    public function rules()
99
    {
100
        return [
101
            ['disqusShortname', 'string'],
102
            ['disqusShortname', 'default', 'value' => ''],
103
            ['useSSO', 'boolean'],
104
            ['useSSO', 'default', 'value' => false],
105
            ['disqusPublicKey', 'string'],
106
            ['disqusPublicKey', 'default', 'value' => ''],
107
            ['disqusSecretKey', 'string'],
108
            ['disqusSecretKey', 'default', 'value' => ''],
109
            ['customLogin', 'boolean'],
110
            ['customLogin', 'default', 'value' => false],
111
            ['loginName', 'string'],
112
            ['loginName', 'default', 'value' => ''],
113
            ['loginButton', 'string'],
114
            ['loginButton', 'default', 'value' => ''],
115
            ['loginIcon', 'string'],
116
            ['loginIcon', 'default', 'value' => ''],
117
            ['loginUrl', 'string'],
118
            ['loginUrl', 'default', 'value' => ''],
119
            ['loginLogoutUrl', 'string'],
120
            ['loginLogoutUrl', 'default', 'value' => ''],
121
            ['loginWidth', 'integer', 'min' => 400, 'max' => 2000],
122
            ['loginWidth', 'default', 'value' => 800],
123
            ['loginHeight', 'integer', 'min' => 200, 'max' => 1000],
124
            ['loginHeight', 'default', 'value' => 400],
125
        ];
126
    }
127
128
129
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
130
     * @return array
131
     */
132
    public function behaviors()
133
    {
134
        $craft31Behaviors = [];
135
        if (Disqus::$craft31) {
136
            $craft31Behaviors = [
137
                'parser' => [
138
                    'class' => EnvAttributeParserBehavior::class,
139
                    'attributes' => [
140
                        'disqusPublicKey',
141
                        'disqusSecretKey',
142
                    ],
143
                ]
144
            ];
145
        }
146
147
        return array_merge($craft31Behaviors, [
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
148
            'typecast' => [
149
                'class' => AttributeTypecastBehavior::class,
150
                // 'attributeTypes' will be composed automatically according to `rules()`
151
            ],
152
        ]);
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
153
    }
154
}
155