Completed
Push — master ( 42b9cd...ad572e )
by Dmitry
06:34
created

ExchangeRate::pairCode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace hipanel\modules\finance\models;
4
5
use hipanel\base\ModelTrait;
6
use hiqdev\hiart\ActiveQuery;
7
use hiqdev\hiart\ActiveRecord;
8
9
/**
10
 * Class ExchangeRate
11
 *
12
 * @property string from
13
 * @property string to
14
 * @property float rate
15
 * @author Dmytro Naumenko <[email protected]>
16
 */
17
class ExchangeRate extends ActiveRecord
18
{
19
    use ModelTrait;
20
21
    public static function tableName()
22
    {
23
        return 'currency';
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     * @return ActiveQuery
29
     */
30
    public static function find()
31
    {
32
        return parent::find()->action('search-rates');
33
    }
34
35
    public function rules()
36
    {
37
        return [
38
            [['from', 'to', 'rate'], 'safe']
39
        ];
40
    }
41
42
    public function pairCode(string $delimiter = '/'): string
43
    {
44
        return implode($delimiter, [$this->from, $this->to]);
45
    }
46
47
    public function attributeLabels()
48
    {
49
        return [
50
            'from' => \Yii::t('hipanel:finance', 'From'),
51
            'to' => \Yii::t('hipanel:finance', 'To'),
52
            'rate' => \Yii::t('hipanel:finance', 'Rate')
53
        ];
54
    }
55
}
56