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

VisitsFixture::load()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 1
dl 0
loc 14
rs 10
c 0
b 0
f 0
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