DefaultHydrator   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A hydrate() 0 14 2
1
<?php
2
3
namespace Swm\Bundle\MailHookBundle\Hydrator;
4
5
use Swm\Bundle\MailHookBundle\Event\HookEventInterface;
6
use Swm\Bundle\MailHookBundle\Hook\HookInterface;
7
use Swm\Bundle\MailHookBundle\Hydrator\HydratorInterface;
8
9
class DefaultHydrator implements HydratorInterface
10
{
11
    /**
12
     * @param  HookInterface $apiService
13
     * @param  string        $entityName
14
     * @return mixed $entityName instance
15
     */
16
    public function hydrate(HookInterface $apiService, $entityName)
17
    {
18
        $hydratedEntity = new $entityName();
19
20
        if (!$hydratedEntity instanceof HookEventInterface) {
21
            throw new LogicException("Can't hydrate this event");
22
        }
23
24
        $hydratedEntity->setEmail($apiService->getEmail());
25
        $hydratedEntity->setName($apiService->getService());
26
        $hydratedEntity->setMetaData($apiService->getMetaData());
27
28
        return $hydratedEntity;
29
    }
30
}
31