Completed
Pull Request — master (#107)
by Tim
24:03 queued 15:37
created

DepartmentManager   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A transform() 0 6 1
1
<?php
2
3
namespace App\Http\TransformersApi\Relations;
4
5
use App\Departments;
6
use League\Fractal;
7
8
/**
9
 * Class DepartmentTransformer
10
 */
11
class DepartmentManager extends Fractal\TransformerAbstract
12
{
13
14
    /**
15
     * Generic array
16
     *
17
     * @param  Departments $manager
18
     * @return array
19
     */
20
    public function transform(Departments $manager)
21
    {
22
        return [
23
            'id'   => (int)    $manager->id,
0 ignored issues
show
Documentation introduced by
The property id does not exist on object<App\Departments>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
24
        ];
25
    }
26
}