Completed
Push — master ( 1671b1...4e9462 )
by Kamil
23:39
created

IndexPage   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 4
c 1
b 1
f 0
lcom 1
cbo 4
dl 0
loc 45
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A isThereProduct() 0 10 2
A getRouteName() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sylius\Behat\Page\Admin\Product;
13
14
use Behat\Mink\Session;
15
use Sylius\Behat\Page\SymfonyPage;
16
use Sylius\Behat\TableManipulatorInterface;
17
use Sylius\Component\Core\Model\ProductInterface;
18
use Symfony\Component\Routing\RouterInterface;
19
20
/**
21
 * @author Magdalena Banasiak <[email protected]>
22
 */
23
class IndexPage extends SymfonyPage implements IndexPageInterface
24
{
25
    /**
26
     * @var TableManipulatorInterface
27
     */
28
    private $tableManipulator;
29
30
    /**
31
     * {@inheritdoc}
32
     *
33
     * @param TableManipulatorInterface $tableManipulator
34
     */
35
    public function __construct(
36
        Session $session,
37
        array $parameters,
38
        RouterInterface $router,
39
        TableManipulatorInterface $tableManipulator
40
    ) {
41
        parent::__construct($session, $parameters, $router);
42
43
        $this->tableManipulator = $tableManipulator;
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49
    public function isThereProduct(ProductInterface $product)
50
    {
51
        if (!$table = $this->getDocument()->find('css', 'table')) {
52
            return false;
53
        }
54
55
        $row = $this->tableManipulator->getRowWithFields($table, ['id' => $product->getId()]);
56
57
        return null === $row;
58
    }
59
60
    /**
61
     * {@inheritdoc}
62
     */
63
    protected function getRouteName()
64
    {
65
        return 'sylius_backend_product_index';
66
    }
67
}
68