FakeEventsSeeder   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 7
dl 0
loc 38
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
B run() 0 26 2
1
<?php
2
3
/**
4
 * Storgman - Student Organizations Management
5
 * Copyright (C) 2014-2016, Dejan Angelov <[email protected]>
6
 *
7
 * This file is part of Storgman.
8
 *
9
 * Storgman is free software: you can redistribute it and/or modify
10
 * it under the terms of the GNU General Public License as published by
11
 * the Free Software Foundation, either version 3 of the License, or
12
 * (at your option) any later version.
13
 *
14
 * Storgman is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with Storgman.  If not, see <http://www.gnu.org/licenses/>.
21
 *
22
 * @package Storgman
23
 * @copyright Copyright (C) 2014-2016, Dejan Angelov <[email protected]>
24
 * @license https://github.com/angelov/storgman/blob/master/LICENSE
25
 * @author Dejan Angelov <[email protected]>
26
 */
27
28
use Angelov\Storgman\Events\Commands\StoreEventCommand;
29
use Angelov\Storgman\Events\EventImage;
30
use Angelov\Storgman\LocalCommittees\Repositories\LocalCommitteesRepositoryInterface;
31
use Carbon\Carbon;
32
use Illuminate\Database\Seeder;
33
34
class FakeEventsSeeder extends Seeder
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...
35
{
36
    protected $faker;
37
    protected $localCommittees;
38
39
    public function __construct(\Faker\Factory $fakerFactory, LocalCommitteesRepositoryInterface $localCommittees)
40
    {
41
        $this->faker = $fakerFactory->create();
42
        $this->localCommittees = $localCommittees;
43
    }
44
45
    public function run()
46
    {
47
        for ($i=0; $i<5; $i++) {
48
49
            $title = $this->faker->catchPhrase();
50
            $description = $this->faker->realText();
51
52
            $lcs = $this->localCommittees->all();
53
            $host = $lcs[rand(0, count($lcs)-1)];
54
55
            $url = $this->faker->url();
56
57
            $image = $this->faker->image($dir = '/tmp', $width = 640, $height = 480);
58
            $image = new EventImage("eventimage.jpg", $image);
59
60
            $startDate = new Carbon($this->faker->dateTimeBetween('now', '+1 month')->format('d-m-Y'));
0 ignored issues
show
Unused Code introduced by
The call to Generator::dateTimeBetween() has too many arguments starting with 'now'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
61
            $endDate = clone  $startDate;
62
            $endDate->addDays(rand(7, 10));
63
            $deadline = (new Carbon())->addDays(rand(3, 10));
64
65
            dispatch(new StoreEventCommand($title, $description, $host->getId(), $url, $image, $startDate, $endDate, $deadline));
66
67
68
69
        }
70
    }
71
}