Radius   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 38.71 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
c 2
b 0
f 0
lcom 0
cbo 1
dl 12
loc 31
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getRadius() 0 4 1
A __construct() 12 12 3

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 Arthem\GoogleApi\Domain\Place\VO;
4
5
use Arthem\GoogleApi\Domain\Place\Exception\InvalidRadiusException;
6
7
class Radius
8
{
9
    /**
10
     * @var float
11
     */
12
    private $radius;
13
14
    /**
15
     * @param int|float $radius
16
     */
17 View Code Duplication
    public function __construct($radius)
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...
18
    {
19
        if (!is_int($radius) && !is_float($radius)) {
20
            throw new InvalidRadiusException(
21
                sprintf(
22
                    'Invalid radius: expected float or int, got %s',
23
                    gettype($radius)
24
                )
25
            );
26
        }
27
        $this->radius = (float) $radius;
28
    }
29
30
    /**
31
     * @return float
32
     */
33
    public function getRadius()
34
    {
35
        return $this->radius;
36
    }
37
}
38