Completed
Push — master ( e7c5cf...05695e )
by Alejandro
17s
created

VisitsFixture   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 21
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A load() 0 14 1
A getDependencies() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
namespace ShlinkioApiTest\Shlink\Rest\Fixtures;
5
6
use Doctrine\Common\DataFixtures\AbstractFixture;
7
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
8
use Doctrine\Common\Persistence\ObjectManager;
9
use Shlinkio\Shlink\Core\Entity\ShortUrl;
10
use Shlinkio\Shlink\Core\Entity\Visit;
11
use Shlinkio\Shlink\Core\Model\Visitor;
12
13
class VisitsFixture extends AbstractFixture implements DependentFixtureInterface
14
{
15
    public function getDependencies(): array
16
    {
17
        return [ShortUrlsFixture::class];
18
    }
19
20
    public function load(ObjectManager $manager): void
21
    {
22
        /** @var ShortUrl $abcShortUrl */
23
        $abcShortUrl = $this->getReference('abc123_short_url');
24
        $manager->persist(new Visit($abcShortUrl, new Visitor('shlink-tests-agent', '', '44.55.66.77')));
25
        $manager->persist(new Visit($abcShortUrl, new Visitor('shlink-tests-agent', 'https://google.com', '4.5.6.7')));
26
        $manager->persist(new Visit($abcShortUrl, new Visitor('shlink-tests-agent', '', '1.2.3.4')));
27
28
        /** @var ShortUrl $defShortUrl */
29
        $defShortUrl = $this->getReference('def456_short_url');
30
        $manager->persist(new Visit($defShortUrl, new Visitor('shlink-tests-agent', '', '127.0.0.1')));
31
        $manager->persist(new Visit($defShortUrl, new Visitor('shlink-tests-agent', 'https://app.shlink.io', '')));
32
33
        $manager->flush();
34
    }
35
}
36