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.

PropertyMapper::map()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 22
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 22
rs 9.2
cc 3
eloc 13
nc 3
nop 2
1
<?php
2
namespace Transmission\Util;
3
4
use Transmission\Model\ModelInterface;
5
use Symfony\Component\PropertyAccess\PropertyAccess;
6
7
/**
8
 * The PropertyMapper is used to map responses from Transmission to models
9
 *
10
 * @author Ramon Kleiss <[email protected]>
11
 */
12
class PropertyMapper
13
{
14
    /**
15
     * @param  ModelInterface $model
16
     * @param  \stdClass                          $dto
17
     * @return ModelInterface
18
     */
19
    public static function map(ModelInterface $model, $dto)
20
    {
21
        $accessor = PropertyAccess::createPropertyAccessor();
22
23
        $mapping  = array_filter($model->getMapping(), function ($value) {
24
            return !is_null($value);
25
        });
26
27
        foreach ($mapping as $source => $dest) {
28
            try {
29
                $accessor->setValue(
30
                    $model,
31
                    $dest,
32
                    $accessor->getValue($dto, $source)
33
                );
34
            } catch (\Exception $e) {
35
                continue;
36
            }
37
        }
38
39
        return $model;
0 ignored issues
show
Bug Compatibility introduced by
The expression return $model; of type object|array is incompatible with the return type documented by Transmission\Util\PropertyMapper::map of type Transmission\Model\ModelInterface as it can also be of type array which is not included in this return type.
Loading history...
40
    }
41
}
42