SlotFinder   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A findSlotInBundleByName() 0 10 3
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