Setting   A
last analyzed

Complexity

Total Complexity 13

Size/Duplication

Total Lines 143
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 7
Bugs 0 Features 2
Metric Value
wmc 13
c 7
b 0
f 2
lcom 1
cbo 0
dl 0
loc 143
ccs 0
cts 54
cp 0
rs 10

11 Methods

Rating   Name   Duplication   Size   Complexity  
A getUserName() 0 4 1
A setUserName() 0 5 1
A getUserPassword() 0 4 1
A setUserPassword() 0 5 1
A getSyncRemove() 0 4 1
A setSyncRemove() 0 5 1
A getSyncInsert() 0 4 1
A setSyncInsert() 0 5 1
A getSyncUpdate() 0 4 1
A setSyncUpdate() 0 5 1
A isPasswordNotEmpty() 0 9 3
1
<?php
2
/**
3
 * AnimeDb package
4
 *
5
 * @package   AnimeDb
6
 * @author    Peter Gribanov <[email protected]>
7
 * @copyright Copyright (c) 2011, Peter Gribanov
8
 * @license   http://opensource.org/licenses/GPL-3.0 GPL v3
9
 */
10
11
namespace AnimeDb\Bundle\MyAnimeListSyncBundle\Entity;
12
13
use Symfony\Component\Validator\Constraints as Assert;
14
use Symfony\Component\Validator\Context\ExecutionContextInterface;
15
16
/**
17
 * Plugin settings
18
 *
19
 * @Assert\Callback(methods={"isPasswordNotEmpty"})
20
 * @package AnimeDb\Bundle\MyAnimeListSyncBundle\Entity
21
 * @author  Peter Gribanov <[email protected]>
22
 */
23
class Setting
24
{
25
    /**
26
     * @var string
27
     */
28
    protected $user_name;
29
30
    /**
31
     * @var string
32
     */
33
    protected $user_password;
34
35
    /**
36
     * @Assert\Type(type="bool", message="The value {{ value }} is not a valid {{ type }}.")
37
     *
38
     * @var bool
39
     */
40
    protected $sync_remove = true;
41
42
    /**
43
     * @Assert\Type(type="bool", message="The value {{ value }} is not a valid {{ type }}.")
44
     *
45
     * @var bool
46
     */
47
    protected $sync_insert = true;
48
49
    /**
50
     * @Assert\Type(type="bool", message="The value {{ value }} is not a valid {{ type }}.")
51
     *
52
     * @var bool
53
     */
54
    protected $sync_update = true;
55
56
    /**
57
     * Get user name
58
     * 
59
     * @return string
60
     */
61
    public function getUserName()
62
    {
63
        return $this->user_name;
64
    }
65
66
    /**
67
     * @param string $user_name
68
     *
69
     * @return Setting
70
     */
71
    public function setUserName($user_name)
72
    {
73
        $this->user_name = $user_name;
74
        return $this;
75
    }
76
77
    /**
78
     * @return string
79
     */
80
    public function getUserPassword()
81
    {
82
        return $this->user_password;
83
    }
84
85
    /**
86
     * @param string $user_password
87
     *
88
     * @return Setting
89
     */
90
    public function setUserPassword($user_password)
91
    {
92
        $this->user_password = $user_password;
93
        return $this;
94
    }
95
96
    /**
97
     * @return bool
98
     */
99
    public function getSyncRemove()
100
    {
101
        return $this->sync_remove;
102
    }
103
104
    /**
105
     * @param bool $sync_remove
106
     *
107
     * @return Setting
108
     */
109
    public function setSyncRemove($sync_remove)
110
    {
111
        $this->sync_remove = $sync_remove;
112
        return $this;
113
    }
114
115
    /**
116
     * @return bool
117
     */
118
    public function getSyncInsert()
119
    {
120
        return $this->sync_insert;
121
    }
122
123
    /**
124
     * @param bool $sync_insert
125
     *
126
     * @return Setting
127
     */
128
    public function setSyncInsert($sync_insert)
129
    {
130
        $this->sync_insert = $sync_insert;
131
        return $this;
132
    }
133
134
    /**
135
     * @return bool
136
     */
137
    public function getSyncUpdate()
138
    {
139
        return $this->sync_update;
140
    }
141
142
    /**
143
     * @param bool $sync_update
144
     *
145
     * @return Setting
146
     */
147
    public function setSyncUpdate($sync_update)
148
    {
149
        $this->sync_update = $sync_update;
150
        return $this;
151
    }
152
153
    /**
154
     * @param ExecutionContextInterface $context
155
     */
156
    public function isPasswordNotEmpty(ExecutionContextInterface $context)
157
    {
158
        if ($this->getUserName() && !$this->getUserPassword()) {
159
            $context
160
                ->buildViolation('Password is required to fill if the username is specified')
161
                ->atPath('user_password')
162
                ->addViolation();
163
        }
164
    }
165
}
166