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   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A map() 0 22 3
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