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
Pull Request — develop (#4)
by Tom Van
03:37
created

guardInvalidArguments()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 5
nc 3
nop 3
1
<?php
2
/**
3
 * Trait with method to validate arguments of ::mapField
4
 * from Exif\*Mapper classes
5
 *
6
 * @link        http://github.com/PHPExif/php-exif-native for the canonical source repository
7
 * @copyright   Copyright (c) 2016 Tom Van Herreweghe <[email protected]>
8
 * @license     http://github.com/PHPExif/php-exif-native/blob/master/LICENSE MIT License
9
 * @category    PHPExif
10
 * @package     Native
11
 */
12
13
namespace PHPExif\Adapter\Native\Reader\Mapper\Exif;
14
15
use PHPExif\Common\Data\ExifInterface;
16
use PHPExif\Common\Exception\Mapper\UnsupportedFieldException;
17
use PHPExif\Common\Exception\Mapper\UnsupportedOutputException;
18
19
/**
20
 * Common method to check the arguments of an Exif\* mapper
21
 *
22
 * @category    PHPExif
23
 * @package     Native
24
 */
25
trait GuardInvalidArgumentsTrait
26
{
27
    /**
28
     * Guard function for invalid arguments
29
     *
30
     * @param string $field
31
     * @param array $input
32
     * @param object $output
33
     *
34
     * @throws UnsupportedFieldException when asked to map an unsupported field
35
     * @throws UnsupportedOutputException when asked to map data on an unsupported output object
36
     *
37
     * @return void
38
     */
39
    private function guardInvalidArguments($field, array $input, $output)
0 ignored issues
show
Unused Code introduced by
The parameter $input is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
40
    {
41
        if (!in_array($field, $this->getSupportedFields())) {
0 ignored issues
show
Bug introduced by
It seems like getSupportedFields() 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...
42
            throw UnsupportedFieldException::forField($field);
43
        }
44
45
        if (!($output instanceof ExifInterface)) {
46
            throw UnsupportedOutputException::forOutput($output);
47
        }
48
    }
49
}
50