Completed
Pull Request — 1.5 (#758)
by Paweł
11:13
created

ContentListContext   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A theFollowingContentLists() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SWP\Behat\Contexts;
6
7
use Behat\Behat\Context\Context;
8
use Behat\Gherkin\Node\TableNode;
9
use Doctrine\ORM\EntityManagerInterface;
10
use SWP\Component\ContentList\Repository\ContentListRepositoryInterface;
11
use SWP\Component\Storage\Factory\FactoryInterface;
12
13
final class ContentListContext extends AbstractContext implements Context
14
{
15
    private $contentListFactory;
16
17
    private $contentListRepository;
18
19
    private $entityManager;
20
21
    public function __construct(FactoryInterface $contentListFactory, ContentListRepositoryInterface $contentListRepository, EntityManagerInterface $entityManager)
22
    {
23
        $this->contentListFactory = $contentListFactory;
24
        $this->contentListRepository = $contentListRepository;
25
        $this->entityManager = $entityManager;
26
    }
27
28
    /**
29
     * @Given the following Content Lists:
30
     */
31
    public function theFollowingContentLists(TableNode $table)
32
    {
33
        foreach ($table as $row => $columns) {
34
            $contentList = $this->contentListFactory->create();
35
            $this->fillObject($contentList, $columns);
36
            $this->entityManager->persist($contentList);
37
        }
38
39
        $this->entityManager->flush();
40
    }
41
}
42