Completed
Push — develop ( 3af89d...cb4d39 )
by
unknown
07:47
created

OrganizationNameStrategy   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A extract() 0 8 2
A hydrate() 0 4 1
1
<?php
2
/**
3
 * YAWIK
4
 *
5
 * @filesource
6
 * @license MIT
7
 * @copyright  2013 - 2017 Cross Solution <http://cross-solution.de>
8
 */
9
  
10
/** */
11
namespace Jobs\Form\Hydrator\Strategy;
12
13
use Zend\Hydrator\Strategy\StrategyInterface;
14
use Organizations\Repository\Organization as OrganizationRepository;
15
16
/**
17
 * ${CARET}
18
 * 
19
 * @author Mathias Gelhausen <[email protected]>
20
 * @todo write test 
21
 */
22
class OrganizationNameStrategy implements StrategyInterface
23
{
24
    /**
25
     *
26
     *
27
     * @var OrganizationRepository
28
     */
29
    private $repository;
30
31
    public function __construct(OrganizationRepository $repository)
32
    {
33
        $this->repository = $repository;
34
    }
35
36
    public function extract($value)
37
    {
38
        if ($value instanceOf \Organizations\Entity\Organization) {
39
            return $value->getId();
40
        }
41
42
        return null;
43
    }
44
45
    public function hydrate($value)
46
    {
47
        return $this->repository->find($value);
48
    }
49
}