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

A001LeaguesSeeder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B run() 0 24 3
1
<?php
2
3
4
class A001LeaguesSeeder
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
        $leagues = [
9
            'friendly' => 5,
10
            'europa league' => 2
11
        ];
12
13
        foreach ($leagues as $league => $dayMatches) {
14
            $league = \App\Lib\DsManager\Models\Orm\League::create(
15
                [
16
                    'name' => $league
17
                ]
18
            );
19
20
            for ($i = 1; $i <= $dayMatches; $i++) {
21
                \App\Lib\DsManager\Models\Orm\MatchDay::create(
22
                    [
23
                        'league_id' => $league->id,
0 ignored issues
show
Documentation introduced by
The property id does not exist on object<App\Lib\DsManager\Models\Orm\League>. 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
                        'day' => $i
25
                    ]
26
                );
27
            }
28
        }
29
    }
30
}