Completed
Push — master ( 543190...5d04a1 )
by Vincenzo
02:30
created

A000TeamsSeeder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 16 3
1
<?php
2
3
4
class A000TeamsSeeder
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
5
{
6
    function run()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
7
    {
8
        $teamNumber = 16;
9
        $rndFiller = new \App\Lib\DsManager\Helpers\RandomFiller();
10
        for ($i = 1; $i <= $teamNumber; $i++) {
11
            $team = $rndFiller->getTeam($rndFiller->getLocale());
12
            $teamArray = $team->toArray();
13
            $teamO = \App\Lib\DsManager\Models\Orm\Team::create($teamArray);
14
            foreach ($teamArray['roster'] as $player) {
15
                $player['team_id'] = $teamO->id;
0 ignored issues
show
Documentation introduced by
The property id does not exist on object<App\Lib\DsManager\Models\Orm\Team>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write 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.");
        }
    }

}

Since the property has write access only, you can use the @property-write 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...
16
                \App\Lib\DsManager\Models\Orm\Player::create($player);
17
            }
18
            $teamArray['coach']['team_id'] = $teamO->id;
0 ignored issues
show
Documentation introduced by
The property id does not exist on object<App\Lib\DsManager\Models\Orm\Team>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write 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.");
        }
    }

}

Since the property has write access only, you can use the @property-write 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...
19
            \App\Lib\DsManager\Models\Orm\Coach::create($teamArray['coach']);
20
        }
21
    }
22
}