Completed
Push — master ( 254490...158eb7 )
by Daniel
11:17
created

TaxationHealth   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 9
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 50
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setHealthFundTax() 0 9 2
A setHealthFndTxBs() 0 13 4
A setHealthTax() 0 9 3
1
<?php
2
3
/*
4
 * The MIT License
5
 *
6
 * Copyright 2018 Daniel Popiniuc
7
 *
8
 * Permission is hereby granted, free of charge, to any person obtaining a copy
9
 * of this software and associated documentation files (the "Software"), to deal
10
 * in the Software without restriction, including without limitation the rights
11
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
 * copies of the Software, and to permit persons to whom the Software is
13
 * furnished to do so, subject to the following conditions:
14
 *
15
 * The above copyright notice and this permission notice shall be included in
16
 * all copies or substantial portions of the Software.
17
 *
18
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
 * THE SOFTWARE.
25
 */
26
27
namespace danielgp\salariu;
28
29
/**
30
 * Description of Taxation
31
 *
32
 * @author E303778
33
 */
34
trait TaxationHealth
35
{
36
37
    /**
38
     * CAS
39
     *
40
     * */
41
    private function setHealthFundTax($lngDate, $lngBrutto, $nPercentages, $nValues) {
42
        $this->txLvl['casP']      = $this->setValuesFromJson($lngDate, $nPercentages);
0 ignored issues
show
Bug introduced by
The property txLvl does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
Bug introduced by
It seems like setValuesFromJson() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
43
        $this->txLvl['casP_base'] = $this->setHealthFndTxBs($lngDate, $lngBrutto, $nValues);
44
        $nReturn                  = $this->txLvl['casP_base'] * $this->txLvl['casP'] / 100;
45
        if ($lngDate > 20060701) {
46
            $nReturn = ceil($nReturn / pow(10, 4)) * pow(10, 4);
47
        }
48
        $this->txLvl['cas'] = round($nReturn, 0);
49
    }
50
51
    /**
52
     * baza CAS
53
     *
54
     * http://www.lapensie.com/forum/salariul-mediu-brut.php
55
     * */
56
    private function setHealthFndTxBs($lngDate, $lngBrutto, $nValues) {
57
        $crtValues = $nValues[substr($lngDate, 0, 4)];
58
        $base      = min($lngBrutto, $crtValues['Multiplier'] * $crtValues['Monthly Average Salary']);
59
        if ($lngDate >= 20170201) {
60
            $base = $lngBrutto;
61
        }
62
        if (array_key_exists('Month Secondary Value', $crtValues)) {
63
            if (substr($lngDate, 4, 2) >= $crtValues['Month Secondary Value']) {
64
                $base = min($lngBrutto, $crtValues['Multiplier'] * $crtValues['Monthly Average Salary Secondary']);
65
            }
66
        }
67
        return $base;
68
    }
69
70
    /**
71
     * Sanatate
72
     * */
73
    protected function setHealthTax($lngDate, $lngBrutto, $nPercentages, $nValues) {
74
        $this->txLvl['sntP'] = $this->setValuesFromJson($lngDate, $nPercentages);
0 ignored issues
show
Bug introduced by
It seems like setValuesFromJson() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
75
        $nReturn             = round($lngBrutto * $this->txLvl['sntP'] / 100, 0);
76
        if ($lngDate >= 20170101) {
77
            $this->txLvl['sntP_base'] = $this->setHealthFndTxBs($lngDate, $lngBrutto, $nValues);
78
            $nReturn                  = round($this->txLvl['sntP_base'] * $this->txLvl['sntP'] / 100, 0);
79
        }
80
        $this->txLvl['snt'] = (($lngDate > 20060701) ? round($nReturn, -4) : $nReturn);
81
    }
82
83
}
84