GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — develop ( e263f3...74da5c )
by Tom Van
23s
created

Resolution   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
cbo 1
dl 26
loc 26
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 18 18 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
 * PHP Exif Resolution ValueObject
4
 *
5
 * @link        http://github.com/PHPExif/php-exif-common for the canonical source repository
6
 * @copyright   Copyright (c) 2016 Tom Van Herreweghe <[email protected]>
7
 * @license     http://github.com/PHPExif/php-exif-common/blob/master/LICENSE MIT License
8
 * @category    PHPExif
9
 * @package     Common
10
 */
11
12
namespace PHPExif\Common\Data\ValueObject;
13
14
use PHPExif\Common\Data\ValueObject\IntegerObject;
15
use \InvalidArgumentException;
16
use \RuntimeException;
17
18
/**
19
 * Resolution class
20
 *
21
 * A value object to describe the Resolution data
22
 *
23
 * @category    PHPExif
24
 * @package     Common
25
 */
26 View Code Duplication
abstract class Resolution extends IntegerObject
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...
27
{
28
    /**
29
     * @param string $stringData
30
     *
31
     * @throws InvalidArgumentException If given argument is not a string
32
     */
33
    public function __construct($stringData)
34
    {
35
        if (!is_string($stringData)) {
36
            throw new InvalidArgumentException('Given data is not a string');
37
        }
38
39
        if (!preg_match('#^([0-9]+)/([0-9]+)$#', $stringData, $matches)) {
40
            throw new RuntimeException('Given resolution is not in a valid format. Need: "<number>/<number>"');
41
        }
42
43
        $numerator = (int) $matches[1];
44
        $denominator = (int) $matches[2];
45
46
        // normalize:
47
        $numerator /= $denominator;
48
49
        $this->setValue($numerator);
50
    }
51
}
52