RmbCent::inYuan()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the overtrue/laravel-revaluation.
5
 *
6
 * (c) overtrue <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Overtrue\LaravelRevaluation\Valuators;
13
14
/**
15
 * Class RmbCent.
16
 */
17
class RmbCent extends Valuator
18
{
19
    public function toDefaultFormat()
20
    {
21
        return $this->inYuan();
22
    }
23
24
    public function inYuan()
25
    {
26
        $precision = config('revaluation.options.rmb.precision', config('revaluation.options.rmb.pricision'));
27
28
        return number_format(round($this->value / 100, $precision), $precision, '.', '');
29
    }
30
31
    public function asCurrency($format = null)
32
    {
33
        return money_format($format ?? config('revaluation.options.rmb.currency_format'), abs($this->inYuan()));
34
    }
35
36
    public static function toStorableValue($value)
37
    {
38
        return null === $value ? null : $value * 100;
39
    }
40
}
41