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

A002MatchesSeeder::run()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 16
rs 9.4285
cc 2
eloc 10
nc 2
nop 0
1
<?php
2
3
4
class A002MatchesSeeder
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
        $teams = \App\Lib\DsManager\Models\Orm\Team::all()->toArray();
9
        $halfTheTeams = count($teams) / 2;
10
        $chunks = array_chunk($teams, $halfTheTeams);
11
        $teamsSlice1 = $chunks[0];
12
        $teamsSlice2 = $chunks[1];
13
        for ($i = 0; $i < $halfTheTeams; $i++) {
14
            \App\Lib\DsManager\Models\Orm\Match::create(
15
                [
16
                    'home_team_id' => $teamsSlice1[$i]['id'],
17
                    'away_team_id' => $teamsSlice2[$i]['id']
18
                ]
19
            );
20
        }
21
    }
22
}