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

OrderContext::getOrderByNumber()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 8
rs 9.4285
cc 1
eloc 4
nc 1
nop 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