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

OrganizationNameStrategy::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 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
}