Completed
Push — 2.1 ( 1e24d9...76e6a2 )
by Dmitry
66:20 queued 62:56
created

SafeValidator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 16
ccs 2
cts 4
cp 0.5
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A validateAttributes() 0 3 1
A validateAttribute() 0 3 1
1
<?php
2
/**
3
 * @link http://www.yiiframework.com/
4
 * @copyright Copyright (c) 2008 Yii Software LLC
5
 * @license http://www.yiiframework.com/license/
6
 */
7
8
namespace yii\validators;
9
10
/**
11
 * SafeValidator serves as a dummy validator whose main purpose is to mark the attributes to be safe for massive assignment.
12
 *
13
 * This class is required because of the way in which Yii determines whether a property is safe for massive assignment, that is,
14
 * when a user submits form data to be loaded into a model directly from the POST data, is it ok for a property to be copied.
15
 * In many cases, this is required but because sometimes properties are internal and you do not want the POST data to be able to
16
 * override these internal values (especially things like database row ids), Yii assumes all values are unsafe for massive assignment
17
 * unless a validation rule exists for the property, which in most cases it will. Sometimes, however, an item is safe for massive assigment but
18
 * does not have a validation rule associated with it - for instance, due to no validation being performed, in which case, you use this class
19
 * as a validation rule for that property. Although it has no functionality, it allows Yii to determine that the property is safe to copy.
20
 *
21
 * @author Qiang Xue <[email protected]>
22
 * @since 2.0
23
 */
24
class SafeValidator extends Validator
25
{
26
    /**
27
     * @inheritdoc
28
     */
29 2
    public function validateAttributes($model, $attributes = null)
30
    {
31 2
    }
32
33
    /**
34
     * @inheritdoc
35
     */
36
    public function validateAttribute($model, $attribute)
37
    {
38
    }
39
}
40