Completed
Pull Request — develop (#2)
by Tom Van
03:35
created

ValidKeysTrait::getValidKeys()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 2
eloc 2
nc 2
nop 0
1
<?php
2
/**
3
 * Trait with methods to manipulate the $validKeys property
4
 *
5
 * @category    PHPExif
6
 * @copyright   Copyright (c) 2016 Tom Van Herreweghe <[email protected]>
7
 * @license     http://github.com/PHPExif/php-exif-exiftool/blob/master/LICENSE MIT License
8
 * @link        http://github.com/PHPExif/php-exif-exiftool for the canonical source repository
9
 * @package     Exiftool
10
 */
11
12
namespace PHPExif\Adapter\Exiftool\Reader\Mapper\Exif;
13
14
/**
15
 * Common methods to manipulate the validKeys property
16
 *
17
 * @category    PHPExif
18
 * @package     Exiftool
19
 */
20
trait ValidKeysTrait
21
{
22
    /**
23
     * Getter for validKeys
24
     *
25
     * @return array
26
     */
27
    public function getValidKeys()
28
    {
29
        return (!property_exists($this, 'validKeys')) ? [] : $this->validKeys;
0 ignored issues
show
Bug introduced by
The property validKeys does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
30
    }
31
32
    /**
33
     * Setter for validKeys
34
     *
35
     * @param array $validKeys
36
     */
37
    public function setValidKeys(array $validKeys)
38
    {
39
        $this->validKeys = $validKeys;
40
    }
41
}
42