Completed
Push — 1.4-password-hashing-2 ( b79be0 )
by Kamil
16:31
created

ShopBillingDataElement   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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