Completed
Push — master ( 4e9462...2570d1 )
by Kamil
18:48
created

IndexPage::getRouteName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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\ShippingMethod;
13
14
use Behat\Mink\Session;
15
use Sylius\Behat\Page\SymfonyPage;
16
use Sylius\Behat\TableManipulatorInterface;
17
use Symfony\Component\Routing\RouterInterface;
18
19
/**
20
 * @author Jan Góralski <[email protected]>
21
 */
22
class IndexPage extends SymfonyPage implements IndexPageInterface
23
{
24
    /**
25
     * @var TableManipulatorInterface
26
     */
27
    private $tableManipulator;
28
29
    /**
30
     * {@inheritdoc}
31
     *
32
     * @param TableManipulatorInterface $tableManipulator
33
     */
34
    public function __construct(
35
        Session $session,
36
        array $parameters,
37
        RouterInterface $router,
38
        TableManipulatorInterface $tableManipulator
39
    ) {
40
        parent::__construct($session, $parameters, $router);
41
42
        $this->tableManipulator = $tableManipulator;
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function isThereShippingMethodNamed($name)
49
    {
50
        if (null === $table = $this->getDocument()->find('css', 'table')) {
51
            return false;
52
        }
53
54
        try {
55
            $row = $this->tableManipulator->getRowWithFields($table, ['name' => $name]);
56
        } catch (\InvalidArgumentException $exception) {
57
            return false;
58
        }
59
60
        return 1 === $row;
61
    }
62
63
    /**
64
     * {@inheritdoc}
65
     */
66
    protected function getRouteName()
67
    {
68
        return 'sylius_backend_shipping_method_index';
69
    }
70
}
71