ArticleFixtures   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 12
c 1
b 0
f 0
dl 0
loc 29
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A load() 0 16 2
A getOrder() 0 3 1
1
<?php
2
3
namespace App\DataFixtures;
4
5
use App\Project\Domain\Article\Entity\Article;
6
use Doctrine\Bundle\FixturesBundle\Fixture;
7
use Doctrine\Common\Collections\ArrayCollection;
8
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
9
use Doctrine\Common\Persistence\ObjectManager;
10
11
class ArticleFixtures extends Fixture implements OrderedFixtureInterface
12
{
13
    public function load(ObjectManager $manager)
14
    {
15
        $faker = \Faker\Factory::create();
16
        for ($i = 0; $i <= 50; $i++) {
17
            $article = new Article();
18
19
            $article->setContributors(
20
                new ArrayCollection([$this->getReference(UserFixtures::TEST_USER)])
21
            );
22
23
            $article->setAuthor($this->getReference(UserFixtures::TEST_USER));
24
            $article->setBody($faker->paragraph);
25
            $article->setTitle($faker->sentence);
26
27
            $manager->persist($article);
28
            $manager->flush();
29
        }
30
    }
31
32
    /**
33
     * Get the order of this fixture
34
     *
35
     * @return integer
36
     */
37
    public function getOrder()
38
    {
39
        return 2;
40
    }
41
}
42