Completed
Push — npm-shrinkwrap ( 52ca24 )
by Kamil
23:13
created

ShipmentShipListener   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A sendConfirmationEmail() 0 7 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\Bundle\AdminBundle\EventListener;
13
14
use Sylius\Bundle\CoreBundle\EmailManager\ShipmentEmailManagerInterface;
15
use Sylius\Component\Core\Model\ShipmentInterface;
16
use Symfony\Component\EventDispatcher\GenericEvent;
17
use Webmozart\Assert\Assert;
18
19
/**
20
 * @author Grzegorz Sadowski <[email protected]>
21
 */
22
final class ShipmentShipListener
23
{
24
    /**
25
     * @var ShipmentEmailManagerInterface
26
     */
27
    private $shipmentEmailManager;
28
29
    /**
30
     * @param ShipmentEmailManagerInterface $shipmentEmailManager
31
     */
32
    public function __construct(ShipmentEmailManagerInterface $shipmentEmailManager)
33
    {
34
        $this->shipmentEmailManager = $shipmentEmailManager;
35
    }
36
37
    /**
38
     * @param GenericEvent $event
39
     */
40
    public function sendConfirmationEmail(GenericEvent $event)
41
    {
42
        $shipment = $event->getSubject();
43
        Assert::isInstanceOf($shipment, ShipmentInterface::class);
44
45
        $this->shipmentEmailManager->sendConfirmationEmail($shipment);
46
    }
47
}
48