Coach   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 48
Duplicated Lines 60.42 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 6
Bugs 0 Features 4
Metric Value
wmc 12
c 6
b 0
f 4
lcom 1
cbo 1
dl 29
loc 48
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A toArray() 7 7 1
A getWage() 10 10 3
B wageOnSkill() 12 12 8

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace App\Lib\DsManager\Models;
4
5
use App\Lib\DsManager\Models\Common\Person;
6
7
8
/**
9
 * Class Coach
10
 * @package App\Lib\DsManager\Models
11
 */
12
class Coach extends Person
13
{
14
	/**
15
	 * @var
16
	 */
17
	public $favouriteModule;
18
19
	/**
20
	 * @return array
21
	 */
22 View Code Duplication
	public function toArray()
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
		$result = parent::toArray();
25
		$result["favouriteModule"] = $this->favouriteModule;
26
		$result["wageReq"] = $this->getWage();
27
		return $result;
28
	}
29
30
	/**
31
	 * @return float
32
	 */
33 View Code Duplication
	public function getWage()
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...
34
	{
35
		if ($this->wageReq == null) {
36
			$wage = $this->wageOnSkill();
37
			$wage += $this->spareChange();
38
			if ($wage < 0) $wage = $wage * (-1);
39
			$this->wageReq = round($wage, 2);
40
		}
41
		return $this->wageReq;
42
	}
43
44
	/**
45
	 * @return float
46
	 */
47 View Code Duplication
	private function wageOnSkill()
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...
48
	{
49
		if ($this->skillAvg > 98) return 5.0;
50
		if ($this->skillAvg > 90) return 3.5;
51
		if ($this->skillAvg > 80) return 2.0;
52
		if ($this->skillAvg > 76) return 1.5;
53
		if ($this->skillAvg > 70) return 1.0;
54
		if ($this->skillAvg > 60) return .76;
55
		if ($this->skillAvg > 50) return .20;
56
		return 0.5;
57
58
	}
59
}