Completed
Push — master ( 714bc2...f165ae )
by Matthias
10s
created

SlotFinder::findSlotInBundleByName()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 5
nc 3
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * Created by solutionDrive GmbH
7
 *
8
 * @copyright 2018 solutionDrive GmbH
9
 */
10
11
namespace solutionDrive\SyliusProductBundlesPlugin\Service;
12
13
use solutionDrive\SyliusProductBundlesPlugin\Entity\ProductBundleInterface;
14
use solutionDrive\SyliusProductBundlesPlugin\Entity\ProductBundleSlotInterface;
15
use solutionDrive\SyliusProductBundlesPlugin\Exception\SlotNotFoundException;
16
17
class SlotFinder implements SlotFinderInterface
18
{
19
    public function findSlotInBundleByName(ProductBundleInterface $bundle, string $name): ProductBundleSlotInterface
20
    {
21
        foreach ($bundle->getSlots() as $slot) {
22
            if ($slot->getName() === $name) {
23
                return $slot;
24
            }
25
        }
26
27
        throw new SlotNotFoundException($name, $bundle);
28
    }
29
}
30