Years   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
c 2
b 0
f 0
lcom 1
cbo 1
dl 29
loc 29
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 6 6 1
A toMilliseconds() 4 4 2

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
 * Loom
4
 * 
5
 * @copyright   Copyright (c) 2014 Warrick Bayman.
6
 * @author		Warrick Bayman <[email protected]>
7
 * @license     MIT License http://opensource.org/licenses/MIT
8
 * 
9
 */
10
11
namespace Loom;
12
13
14
/**
15
 * Class Years
16
 *
17
 * @package Loom
18
 */
19 View Code Duplication
class Years extends AbstractUnit
0 ignored issues
show
Duplication introduced by
This class 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...
20
{
21
    const SOLAR_DAYS = 365.2521897;
22
23
    private $solar;
24
25
26
    /**
27
     * @param int  $value
28
     * @param bool $solar
29
     */
30
    public function __construct($value, $solar = false)
31
    {
32
        parent::__construct($value);
33
34
        $this->solar = $solar;
35
    }
36
37
38
    /**
39
     * Return the years in milliseconds
40
     *
41
     * @return int
42
     */
43
    public function toMilliseconds()
44
    {
45
        return $this->value * ($this->solar ? self::SOLAR_DAYS : 365) * 24 * 60 * 60 * 1000;
46
    }
47
}
48