Completed
Push — master ( f9a038...cc9983 )
by Kamil
22:34
created

OrderContext   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getOrderByNumber() 0 8 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\Context\Transform;
13
14
use Behat\Behat\Context\Context;
15
use Sylius\Component\Core\Repository\OrderRepositoryInterface;
16
use Webmozart\Assert\Assert;
17
18
/**
19
 * @author Grzegorz Sadowski <[email protected]>
20
 */
21
final class OrderContext implements Context
22
{
23
    /**
24
     * @var OrderRepositoryInterface
25
     */
26
    private $orderRepository;
27
28
    /**
29
     * @param OrderRepositoryInterface $orderRepository
30
     */
31
    public function __construct(OrderRepositoryInterface $orderRepository)
32
    {
33
        $this->orderRepository = $orderRepository;
34
    }
35
36
    /**
37
     * @Transform :order
38
     */
39
    public function getOrderByNumber($orderNumber)
40
    {
41
        $order = $this->orderRepository->findOneBy(['number' => $orderNumber]);
42
43
        Assert::notNull($order, sprintf('Cannot find order with number %s', $orderNumber));
44
45
        return $order;
46
    }
47
}
48