Completed
Branch develop (bc6cb3)
by Carsten
37:10 queued 26:53
created

viewModelTemplateFilterAbstract::setDescription()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 14
rs 8.8571
cc 5
eloc 8
nc 5
nop 0
1
<?php
2
/**
3
 * YAWIK
4
 *
5
 * @filesource
6
 * @copyright (c) 2013-2015 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 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 (^[A-Z][a-zA-Z0-9]*$).

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...
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 assemples 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->template . '/index');
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...
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
     * @return $this
142
     * @throws \InvalidArgumentException
143
     */
144
    protected function setUriApply()
145
    {
146
        if (!isset($this->job)) {
147
            throw new \InvalidArgumentException('cannot create a viewModel for Templates without an $job');
148
        }
149
        $atsMode = $this->job->getAtsMode();
150
        $uriApply = false;
151
        if ($atsMode->isIntern() || $atsMode->isEmail()) {
152
            $uriApply = $this->urlPlugin->fromRoute('lang/apply', array('applyId' => $this->job->applyId), array('force_canonical' => true));
0 ignored issues
show
Documentation introduced by
The property $applyId 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...
153
        } elseif ($atsMode->isUri()) {
154
            $uriApply = $atsMode->getUri();
155
        }
156
        $this->container['uriApply'] = $uriApply;
157
        return $this;
158
    }
159
160
    /**
161
     * @return $this
162
     * @throws \InvalidArgumentException
163
     */
164
    protected function setLocation()
165
    {
166
        if (!isset($this->job)) {
167
            throw new \InvalidArgumentException('cannot create a viewModel for Templates without an $job');
168
        }
169
        $location = $this->job->getLocation();
170
        $this->container['location'] = isset($location)?$location:'';
171
        return $this;
172
    }
173
174
    /**
175
     * Sets the company description of a job. Use the description of an organization as default
176
     *
177
     * @return $this
178
     * @throws \InvalidArgumentException
179
     */
180
    protected function setDescription()
181
    {
182
        if (!isset($this->job)) {
183
            throw new \InvalidArgumentException('cannot create a viewModel for Templates without an $job');
184
        }
185
186
        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 $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...
Documentation introduced by
The property description does not exist on object<Jobs\Entity\TemplateValues>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read 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.");
        }
    }

}

If the property has read access only, you can use the @property-read 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...
187
            $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 $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...
Documentation introduced by
The property description does not exist on object<Jobs\Entity\TemplateValues>. Since you implemented __set, maybe consider adding a @property annotation.

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...
188
        }
189
        $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 does not exist on object<Jobs\Entity\TemplateValues>. Since you implemented __set, maybe consider adding a @property annotation.

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...
190
191
        $this->container['description'] = isset($description)?$description:'';
192
        return $this;
193
    }
194
195
    /**
196
     * @return $this
197
     * @throws \InvalidArgumentException
198
     */
199
    protected function setOrganizationInfo()
200
    {
201
        if (!isset($this->job)) {
202
            throw new \InvalidArgumentException('cannot create a viewModel for Templates without an $job');
203
        }
204
        $organizationName = '';
205
        $organizationStreet = '';
206
        $organizationPostalCode = '';
207
        $organizationPostalCity = '';
208
        $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...
209
        if (isset($organization)) {
210
            $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...
211
            $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...
212
            $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...
213
            $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...
214
        }
215
        $this->container['organizationName'] = $organizationName;
216
        $this->container['street'] = $organizationStreet;
217
        $this->container['postalCode'] = $organizationPostalCode;
218
        $this->container['city'] = $organizationPostalCity;
219
220
        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...
221
            $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...
222
        } else {
223
            $this->container['uriLogo'] = $this->makeAbsolutePath($this->config->default_logo);
224
        }
225
        return $this;
226
    }
227
228
    /**
229
     * @return $this
230
     */
231
    protected function setTemplate()
232
    {
233
        $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...
234
        return $this;
235
    }
236
237
    /**
238
     * combines two helper
239
     * @param $path
240
     * @return mixed
241
     */
242
    protected function makeAbsolutePath($path)
243
    {
244
        $path = $this->serverUrlHelper->__invoke($this->basePathHelper->__invoke($path));
245
        return $path;
246
    }
247
}
248