Completed
Push — develop ( f508dd...35e5c6 )
by Mathias
20:45 queued 12:46
created

JobOrganizationName   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 4
dl 0
loc 25
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 13 3
1
<?php
2
/**
3
 * YAWIK
4
 *
5
 * @filesource
6
 * @license MIT
7
 * @copyright  2013 - 2018 Cross Solution <http://cross-solution.de>
8
 */
9
  
10
/** */
11
namespace Jobs\View\Helper;
12
13
use Jobs\Entity\JobInterface;
14
use Zend\View\Helper\AbstractHelper;
15
16
/**
17
 * Returns the organization name for a job.
18
 *
19
 * It will determine the name in the following order
20
 *
21
 * 1. the value stored in the job's copmany field.
22
 * 2. the organization name of the associated organization.
23
 * 3. the default value
24
 * 
25
 * @author Mathias Gelhausen <[email protected]>
26
 *
27
 */
28
class JobOrganizationName extends AbstractHelper
29
{
30
31
    /**
32
     * Get the organization name.
33
     *
34
     * @param JobInterface $job
35
     * @param string  $default
36
     *
37
     * @return string
38
     */
39
    public function __invoke(JobInterface $job, $default = '')
40
    {
41
        /* @var \Jobs\Entity\Job $job */
42
        if ($orgName = $job->getCompany(/*useOrganizationEntity*/ false)) {
43
            return $orgName;
44
        }
45
46
        if ($org = $job->getOrganization()) {
47
            return $org->getOrganizationName()->getName();
48
        }
49
50
        return $default;
51
    }
52
}
53