Completed
Push — develop ( 0bfa91...da5abe )
by
unknown
08:59 queued 15s
created

ViewModelTemplateFilterAbstract::setApplyData()   C

Complexity

Conditions 7
Paths 7

Size

Total Lines 27
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 27
rs 6.7272
cc 7
eloc 16
nc 7
nop 0
1
<?php
2
/**
3
 * YAWIK
4
 *
5
 * @filesource
6
 * @copyright (c) 2013 - 2016 Cross Solution (http://cross-solution.de)
7
 * @license   MIT
8
 * @author    [email protected]
9
 */
10
11
12
namespace Jobs\Filter;
13
14
use Jobs\Entity\Job;
15
use Zend\Filter\FilterInterface;
16
use Zend\View\Model\ViewModel;
17
18
/**
19
 * assembles a ViewModel for job templates.
20
 * this class needs to be extended for specific assignments
21
 * Class viewModelTemplateFilterAbstract
22
 * @package Jobs\Filter
23
 */
24
abstract class ViewModelTemplateFilterAbstract implements FilterInterface
0 ignored issues
show
Coding Style introduced by
ViewModelTemplateFilterAbstract does not seem to conform to the naming convention (^Abstract|Factory$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
25
{
26
27
    /**
28
     * @var array assembles all data for the viewmodel
29
     */
30
    protected $container;
31
32
    /**
33
     * @var Job
34
     */
35
    protected $job;
36
37
    /**
38
     * @var array
39
     */
40
    protected $config;
41
42
    /**
43
     * creating absolute links like the apply-link
44
     * absolute links are needed on the server of the provider
45
     * @var
46
     */
47
    protected $urlPlugin;
48
49
    /**
50
     * also needed to create absolute links
51
     * @var
52
     */
53
    protected $basePathHelper;
54
55
    /**
56
     * @var
57
     */
58
    protected $serverUrlHelper;
59
60
    /**
61
     * @param $config
62
     */
63
    public function setConfig($config)
64
    {
65
        $this->config = $config;
66
        return;
67
    }
68
69
    /**
70
     * @param $urlPlugin
71
     */
72
    public function setUrlPlugin($urlPlugin)
73
    {
74
        $this->urlPlugin = $urlPlugin;
75
        return;
76
    }
77
78
    /**
79
     * @param $basePathHelper
80
     */
81
    public function setBasePathHelper($basePathHelper)
82
    {
83
        $this->basePathHelper = $basePathHelper;
84
        return;
85
    }
86
87
    /**
88
     * @return mixed
89
     */
90
    public function getBasePathHelper()
91
    {
92
        return $this->basePathHelper;
93
    }
94
95
    /**
96
     * @param $serverUrlHelper
97
     */
98
    public function setServerUrlHelper($serverUrlHelper)
99
    {
100
        $this->serverUrlHelper = $serverUrlHelper;
101
        return;
102
    }
103
104
	/**
105
     * @return mixed
106
     */
107
    public function getServerUrlHelper()
108
    {
109
        return $this->serverUrlHelper;
110
    }
111
112
    /**
113
     * @param mixed $value
114
     * @return mixed|ViewModel
115
     * @throws \InvalidArgumentException
116
     */
117
    public function filter($value)
118
    {
119
        $model = new ViewModel();
120
        $this->container = array();
121
        $this->extract($value);
122
        $model->setVariables($this->container);
123
        if (!isset($this->job)) {
124
            throw new \InvalidArgumentException('cannot create a viewModel for Templates without an $job');
125
        }
126
        $model->setTemplate('templates/' . $this->job->getTemplate() . '/index');
127
        return $model;
128
    }
129
130
    /**
131
     * should be overwritten
132
     * here are all assignments to container arr administered
133
     * input-attributes are the job and the configuration
134
     * output-attribute is the container
135
     * @param $value
136
     * @return mixed
137
     */
138
    abstract protected function extract($value);
139
140
    /**
141
     * Set the apply buttons of the job posting
142
     *
143
     * @return ViewModelTemplateFilterAbstract
144
     * @throws \InvalidArgumentException
145
     */
146
    protected function setApplyData()
147
    {
148
        if (!isset($this->job)) {
149
            throw new \InvalidArgumentException('cannot create a viewModel for Templates without a $job');
150
        }
151
        
152
        $data = [
153
            'applyId' => $this->job->getApplyId(),
154
            'uri' => null,
155
            'oneClickProfiles' => []
156
        ];
157
        $atsMode = $this->job->getAtsMode();
158
        
159
        if ($atsMode->isIntern() || $atsMode->isEmail()) {
160
            $data['uri'] = $this->urlPlugin->fromRoute('lang/apply', ['applyId' => $this->job->getApplyId()], ['force_canonical' => true]);
161
        } elseif ($atsMode->isUri()) {
162
            $data['uri'] = $atsMode->getUri();
163
        }
164
        
165
        if ($atsMode->isIntern() && $atsMode->getOneClickApply()) {
166
            $data['oneClickProfiles'] = $atsMode->getOneClickApplyProfiles();
167
        }
168
        
169
        $this->container['applyData'] = $data;
170
        
171
        return $this;
172
    }
173
174
    /**
175
     * Sets the location of a jobs
176
     *
177
     * @return $this
178
     * @throws \InvalidArgumentException
179
     */
180
    protected function setLocation()
181
    {
182
        if (!isset($this->job)) {
183
            throw new \InvalidArgumentException('cannot create a viewModel for Templates without aa $job');
184
        }
185
        $location = $this->job->getLocation();
186
        $this->container['location'] = isset($location)?$location:'';
187
        return $this;
188
    }
189
190
    /**
191
     * Sets the company description of a job. Use the description of an organization as default
192
     *
193
     * @return $this
194
     * @throws \InvalidArgumentException
195
     */
196
    protected function setDescription()
197
    {
198
        if (!isset($this->job)) {
199
            throw new \InvalidArgumentException('cannot create a viewModel for Templates without a $job');
200
        }
201
202
        if (empty($this->job->templateValues->description) && isset($this->job->organization)) {
0 ignored issues
show
Documentation introduced by
The property $templateValues is declared protected in Jobs\Entity\Job. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Documentation introduced by
The property $description is declared protected in Jobs\Entity\TemplateValues. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Documentation introduced by
The property $organization is declared protected in Jobs\Entity\Job. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
203
            $this->job->templateValues->description = $this->job->organization->description;
0 ignored issues
show
Documentation introduced by
The property $templateValues is declared protected in Jobs\Entity\Job. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Documentation introduced by
The property $description is declared protected in Jobs\Entity\TemplateValues. Since you implemented __set(), maybe consider adding a @property or @property-write annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Documentation introduced by
The property $organization is declared protected in Jobs\Entity\Job. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Bug introduced by
Accessing description on the interface Organizations\Entity\OrganizationInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
204
        }
205
        $description = $this->job->templateValues->description;
0 ignored issues
show
Documentation introduced by
The property $templateValues is declared protected in Jobs\Entity\Job. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
Documentation introduced by
The property $description is declared protected in Jobs\Entity\TemplateValues. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
206
207
        $this->container['description'] = isset($description)?$description:'';
208
        return $this;
209
    }
210
211
    /**
212
     * Sets the organizations contact address
213
     *
214
     * @return $this
215
     * @throws \InvalidArgumentException
216
     */
217
    protected function setOrganizationInfo()
218
    {
219
        if (!isset($this->job)) {
220
            throw new \InvalidArgumentException('cannot create a viewModel for Templates without a $job');
221
        }
222
        $organizationName = '';
0 ignored issues
show
Unused Code introduced by
$organizationName is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
223
        $organizationStreet = '';
0 ignored issues
show
Unused Code introduced by
$organizationStreet is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
224
        $organizationPostalCode = '';
0 ignored issues
show
Unused Code introduced by
$organizationPostalCode is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
225
        $organizationPostalCity = '';
0 ignored issues
show
Unused Code introduced by
$organizationPostalCity is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
226
        $organization = $this->job->organization;
0 ignored issues
show
Documentation introduced by
The property $organization is declared protected in Jobs\Entity\Job. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
227
        $user = $this->job->getUser();
228
229
        if (isset($organization)) {
230
            $organizationName = $organization->organizationName->name;
0 ignored issues
show
Bug introduced by
Accessing organizationName on the interface Organizations\Entity\OrganizationInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
231
            $organizationStreet = $organization->contact->street.' '.$organization->contact->houseNumber;
0 ignored issues
show
Bug introduced by
Accessing contact on the interface Organizations\Entity\OrganizationInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
232
            $organizationPostalCode = $organization->contact->postalcode;
0 ignored issues
show
Bug introduced by
Accessing contact on the interface Organizations\Entity\OrganizationInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
233
            $organizationPostalCity = $organization->contact->city;
0 ignored issues
show
Bug introduced by
Accessing contact on the interface Organizations\Entity\OrganizationInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
234
            $organizationPhone = $organization->contact->phone;
0 ignored issues
show
Bug introduced by
Accessing contact on the interface Organizations\Entity\OrganizationInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
235
            $organizationFax = $organization->contact->fax;
0 ignored issues
show
Bug introduced by
Accessing contact on the interface Organizations\Entity\OrganizationInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
236
        } else {
237
            $organizationName =
238
            $organizationStreet =
239
            $organizationPostalCode =
240
            $organizationPostalCity =
241
            $organizationPhone =
242
            $organizationFax = '';
243
        }
244
        $this->container['contactEmail'] = $user ? $user->getInfo()->getEmail() : '';
245
        $this->container['organizationName'] = $organizationName;
246
        $this->container['street'] = $organizationStreet;
247
        $this->container['postalCode'] = $organizationPostalCode;
248
        $this->container['city'] = $organizationPostalCity;
249
        $this->container['phone'] = $organizationPhone;
250
        $this->container['fax'] = $organizationFax;
251
252
        if (isset($organization) && isset($organization->image) && $organization->image->uri) {
0 ignored issues
show
Bug introduced by
Accessing image on the interface Organizations\Entity\OrganizationInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
253
            $this->container['uriLogo'] = $this->makeAbsolutePath($organization->image->uri);
0 ignored issues
show
Bug introduced by
Accessing image on the interface Organizations\Entity\OrganizationInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
254
        } else {
255
            $this->container['uriLogo'] = $this->makeAbsolutePath($this->config->default_logo);
256
        }
257
        return $this;
258
    }
259
260
    /**
261
     * Sets the default values of an organizations job template
262
     *
263
     * @return $this
264
     * @throws \InvalidArgumentException
265
     */
266
    protected function setTemplateDefaultValues()
267
    {
268
        if (!isset($this->job)) {
269
            throw new \InvalidArgumentException('cannot create a viewModel for Templates without a $job');
270
        }
271
        $labelQualifications='';
272
        $labelBenefits='';
273
        $labelRequirements='';
274
275
        $organization = $this->job->organization;
0 ignored issues
show
Documentation introduced by
The property $organization is declared protected in Jobs\Entity\Job. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
276
        if (isset($organization)) {
277
            $labelRequirements = $organization->getTemplate()->getLabelRequirements();
278
            $labelQualifications = $organization->getTemplate()->getLabelQualifications();
279
            $labelBenefits = $organization->getTemplate()->getLabelBenefits();
280
        }
281
        $this->container['labelRequirements'] = $labelRequirements;
282
        $this->container['labelQualifications'] = $labelQualifications;
283
        $this->container['labelBenefits'] = $labelBenefits;
284
285
        return $this;
286
    }
287
288
    /**
289
     * Sets the template
290
     *
291
     * @return $this
292
     */
293
    protected function setTemplate()
294
    {
295
        $this->container['templateName'] = $this->job->template;
0 ignored issues
show
Documentation introduced by
The property $template is declared protected in Jobs\Entity\Job. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
296
        return $this;
297
    }
298
299
    /**
300
     * combines two helper
301
     *
302
     * @param $path
303
     * @return mixed
304
     */
305
    protected function makeAbsolutePath($path)
306
    {
307
        $path = $this->serverUrlHelper->__invoke($this->basePathHelper->__invoke($path));
308
        return $path;
309
    }
310
}
311