Completed
Push — master ( bbd2b1...f08c3b )
by Kamil
31:47 queued 09:37
created

ShopBillingDataElement   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 10
lcom 1
cbo 2
dl 0
loc 52
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A specifyCompany() 0 4 1
A specifyTaxId() 0 4 1
A specifyBillingAddress() 0 7 1
A hasCompany() 0 4 1
A hasTaxId() 0 4 1
A hasBillingAddress() 0 9 4
A getDefinedElements() 0 11 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
declare(strict_types=1);
13
14
namespace Sylius\Behat\Element\Admin\Channel;
15
16
use FriendsOfBehat\PageObjectExtension\Element\Element;
17
18
final class ShopBillingDataElement extends Element implements ShopBillingDataElementInterface
19
{
20
    public function specifyCompany(string $company): void
21
    {
22
        $this->getElement('company')->setValue($company);
23
    }
24
25
    public function specifyTaxId(string $taxId): void
26
    {
27
        $this->getElement('tax_id')->setValue($taxId);
28
    }
29
30
    public function specifyBillingAddress(string $street, string $postcode, string $city, string $countryCode): void
31
    {
32
        $this->getElement('street')->setValue($street);
33
        $this->getElement('postcode')->setValue($postcode);
34
        $this->getElement('city')->setValue($city);
35
        $this->getElement('country_code')->setValue($countryCode);
36
    }
37
38
    public function hasCompany(string $company): bool
39
    {
40
        return $company === $this->getElement('company')->getValue();
41
    }
42
43
    public function hasTaxId(string $taxId): bool
44
    {
45
        return $taxId === $this->getElement('tax_id')->getValue();
46
    }
47
48
    public function hasBillingAddress(string $street, string $postcode, string $city, string $countryCode): bool
49
    {
50
        return
51
            $street === $this->getElement('street')->getValue() &&
52
            $postcode === $this->getElement('postcode')->getValue() &&
53
            $city === $this->getElement('city')->getValue() &&
54
            $countryCode === $this->getElement('country_code')->getValue()
55
        ;
56
    }
57
58
    protected function getDefinedElements(): array
59
    {
60
        return array_merge(parent::getDefinedElements(), [
61
            'city' => '#sylius_channel_shopBillingData_city',
62
            'company' => '#sylius_channel_shopBillingData_company',
63
            'country_code' => '#sylius_channel_shopBillingData_countryCode',
64
            'postcode' => '#sylius_channel_shopBillingData_postcode',
65
            'street' => '#sylius_channel_shopBillingData_street',
66
            'tax_id' => '#sylius_channel_shopBillingData_taxId',
67
        ]);
68
    }
69
}
70