MagicPropertiesTrait::__set()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12

Duplication

Lines 12
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 12
loc 12
ccs 0
cts 12
cp 0
rs 9.8666
c 0
b 0
f 0
cc 3
nc 3
nop 2
crap 12
1
<?php
2
/**
3
 * @link https://github.com/yiiviet/yii2-payment
4
 * @copyright Copyright (c) 2017 Yii2VN
5
 * @license [New BSD License](http://www.opensource.org/licenses/bsd-license.php)
6
 */
7
8
namespace yiiviet\payment\vnpayment;
9
10
/**
11
 * Trait MagicPropertiesTrait là trait bổ sung phương thức getter và setter nhầm giảm hóa sự lập đi lập lại của prefix `vnp_`
12
 *
13
 * @author Vuong Minh <[email protected]>
14
 * @since 1.0
15
 */
16
trait MagicPropertiesTrait
17
{
18
    /**
19
     * @inheritdoc
20
     * @throws \yii\base\UnknownPropertyException
21
     */
22 View Code Duplication
    public function __get($name)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
23
    {
24
        try {
25
            return parent::__get($name);
26
        } catch (\yii\base\UnknownPropertyException $e) {
27
            if (isset($this["vnp_$name"])) {
28
                return $this["vnp_$name"];
29
            } else {
30
                throw $e;
31
            }
32
        }
33
    }
34
35
    /**
36
     * @inheritdoc
37
     * @throws \yii\base\UnknownPropertyException
38
     */
39 View Code Duplication
    public function __set($name, $value)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
40
    {
41
        try {
42
            parent::__set($name, $value);
43
        } catch (\yii\base\UnknownPropertyException $e) {
44
            if (isset($this["vnp_$name"])) {
45
                $this["vnp_$name"] = $value;
46
            } else {
47
                throw $e;
48
            }
49
        }
50
    }
51
52
}
53