RmbCent   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 24
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A toDefaultFormat() 0 4 1
A inYuan() 0 6 1
A asCurrency() 0 4 1
A toStorableValue() 0 4 2
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