Issues (97)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/Models/Change.php (38 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Audit\Models;
4
5
use DB;
6
use Facilitador;
7
use Config;
8
use PedreiroURL;
9
use Illuminate\Support\Str;
10
use Pedreiro\Template\Input\Search;
11
use Muleta\Library\Utils\Text;
12
use Illuminate\Database\Eloquent\Model;
13
use Audit\Models\Base;
14
use App\Models\User;
15
16
/**
17
 * Reperesents a single model change event.  Typically a single CRUD action on
18
 * a model.
19
 */
20
class Change extends Base
21
{
22
    /**
23
     * The query param key used when previewing
24
     *
25
     * @var string
26
     */
27
    const QUERY_KEY = 'view-change';
28
29
    /**
30
     * The attributes that should be cast to native types.
31
     *
32
     * @var array
33
     */
34
    protected $casts = [
35
        'changed' => 'array',
36
    ];
37
38
    protected $fillable = [
39
        'admin',
40
        'key',
41
        'changeable_id',
42
        'changed',
43
        'deleted',
44
        
45
        'action',
46
        'model',
47
        'model_title',
48
        'date',
49
        'title',
50
        'meta',
51
    ];
52
53
    /**
54
     * Get the admin associated with the change
55
     *
56
     * @return Illuminate\Database\Eloquent\Relations\Relation
57
     */
58
    public function admin()
59
    {
60
        return $this->belongsTo(\Illuminate\Support\Facades\Config::get('sitec.core.models.user', \App\Models\User::class));
61
    }
62
63
    /**
64
     * The polymorphic relation back to the parent model
65
     *
66
     * @var mixed
67
     */
68
    public function loggable()
69
    {
70
        return $this->morphTo('loggable', 'model', 'key');
71
    }
72
73
    /**
74
     * Get the related model, including trashed instances
75
     *
76
     * @return Model
77
     */
78
    public function changedModel()
79
    {
80
        return $this->loggable()->withTrashed();
81
    }
82
83
    /**
84
     * Default ordering by descending time, designed to be overridden
85
     *
86
     * @param  Illuminate\Database\Query\Builder $query
87
     * @return Illuminate\Database\Query\Builder
88
     */
89
    public function scopeOrdered($query)
90
    {
91
        return $query->orderBy('changes.id', 'desc')->with('admin');
92
    }
93
94
    /**
95
     * Don't log changes
96
     *
97
     * @param  string $action
98
     * @return boolean
99
     */
100
    public function shouldLogChange($action)
0 ignored issues
show
The parameter $action is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
101
    {
102
        return false;
103
    }
104
105
    /**
106
     * A convenience method for saving a change instance
107
     *
108
     * @param  Model  $model  The model being touched
109
     * @param  string $action Generally a CRUD verb: "created", "updated", "deleted"
110
     * @param  User   $admin  The admin acting on the record
111
     * @return static|void
112
     */
113
    public static function log(Model $model, $action, User $admin = null)
114
    {
115
        // Create a new change instance
116
        if (static::shouldWriteChange($model, $action)) {
0 ignored issues
show
Since shouldWriteChange() is declared private, calling it with static will lead to errors in possible sub-classes. You can either use self, or increase the visibility of shouldWriteChange() to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
}

public static function getSomeVariable()
{
    return static::getTemperature();
}

}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass {
      private static function getTemperature() {
        return "-182 °C";
    }
}

print YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
    }

    public static function getSomeVariable()
    {
        return self::getTemperature();
    }
}
Loading history...
117
            $changed = static::getChanged($model, $action);
0 ignored issues
show
Since getChanged() is declared private, calling it with static will lead to errors in possible sub-classes. You can either use self, or increase the visibility of getChanged() to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
}

public static function getSomeVariable()
{
    return static::getTemperature();
}

}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass {
      private static function getTemperature() {
        return "-182 °C";
    }
}

print YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class YourClass
{
    private static function getTemperature() {
        return "3422 °C";
    }

    public static function getSomeVariable()
    {
        return self::getTemperature();
    }
}
Loading history...
118
            $change = static::createLog($model, $action, $admin, $changed);
119
        }
120
121
        // Log published / unpblished changes
122
        static::logPublishingChange($model, $action, $admin);
123
124
        // If the action was a deletion, mark all of the records for this model as
125
        // deleted
126
        if ($action == 'deleted') {
127
            DB::table('changes')
128
                ->where('model', get_class($model))
129
                ->where('key', $model->getKey())
130
                ->update(['deleted' => 1]);
131
        }
132
133
        // Return the changed instance
134
        if (isset($change)) {
135
            return $change;
136
        }
137
    }
138
139
    /**
140
     * Don't log changes when the only thing that changed was the published
141
     * state or updated timestamp.  We check if there are any attributes
142
     * besides these that changed.
143
     *
144
     * @param  Model  $model  The model being touched
145
     * @param  string $action
146
     * @return boolean
147
     */
148
    static private function shouldWriteChange(Model $model, $action)
149
    {
150
        if (in_array($action, ['created', 'deleted'])) { return true;
151
        }
152
        $changed_attributes = array_keys($model->getDirty());
153
        $ignored = ['updated_at', 'public'];
154
        $loggable = array_diff($changed_attributes, $ignored);
155
        return count($loggable) > 0;
156
    }
157
158
    /**
159
     * Get the changes attributes
160
     *
161
     * @param  Model  $model  The model being touched
162
     * @param  string $action
163
     * @return array|null
164
     */
165
    static private function getChanged(Model $model, $action)
166
    {
167
        $changed = $model->getDirty();
168
        if ($action == 'deleted' || empty($changed)) {
169
            $changed = null;
170
        }
171
        return $changed;
172
    }
173
174
    /**
175
     * Create a change entry
176
     *
177
     * @param Model  $model  Th
178
     * @param string $action
179
     * @param User   $admin
180
     */
181
    static protected function createLog(
182
        Model $model,
183
        $action,
184
        User $admin = null,
185
        $changed = null
186
    ) {
187
        return static::create(
0 ignored issues
show
The method create() does not exist on Audit\Models\Change. Did you maybe mean createLog()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
188
            [
189
            'model' => get_class($model),
190
            'key' => $model->getKey(),
191
            'action' => $action,
192
            'title' => static::getModelTitle($model),
193
            'changed' => $changed,
194
            'changeable_id' => static::getAdminId($admin),
195
            ]
196
        );
197
    }
198
199
    /**
200
     * Get the title of the model
201
     *
202
     * @param  Model $model
203
     * @return string
204
     */
205
    static protected function getModelTitle(Model $model)
206
    {
207
        return method_exists($model, 'getAdminTitleAttribute') ?
208
            $model->getAdminTitleAttribute() : null;
209
    }
210
211
    /**
212
     * Get the admin id
213
     *
214
     * @param  User $admin
215
     * @return integer
216
     */
217
    static protected function getAdminId(User $admin = null)
218
    {
219
        if (!$admin) {
220
            $admin = app('facilitador.user');
221
        }
222
        return $admin ? $admin->getKey() : null;
223
    }
224
225
    /**
226
     * Log changes to publishing state.  The initial publish should be logged
227
     * but not an initil unpublished state.
228
     *
229
     * @param  Model  $model
230
     * @param  string $action
231
     * @param  User   $admin
232
     * @return void
233
     */
234
    static public function logPublishingChange(
235
        Model $model,
236
        $action,
237
        User $admin = null
238
    ) {
239
        if ($model->isDirty('public')) {
240
            if ($model->public) {
241
                static::createLog($model, 'published', $admin);
242
            } else if (!$model->public && $action != 'created') {
243
                static::createLog($model, 'unpublished', $admin);
244
            }
245
        }
246
    }
247
248
    /**
249
     * Return a list of all the actions currently being used as a hash for use
250
     * in a select menu
251
     *
252
     * @return array
253
     */
254
    public static function getActions()
255
    {
256
        return static::groupBy('action')->pluck('action', 'action')
257
            ->mapWithKeys(
258
                function ($item) {
259
                    return [$item => __("facilitador::changes.actions.$item")];
260
                }
261
            );
262
    }
263
264
    /**
265
     * Return a list of all the admins as a hash for use in a select menu
266
     *
267
     * @return array
268
     */
269
    public static function getAdmins()
270
    {
271
        return User::all(['id', 'email'])->pluck('email', 'id');
272
    }
273
274
    /**
275
     * Format the the activity like a sentence
276
     *
277
     * @return string HTML
278
     */
279
    public function getAdminTitleHtmlAttribute()
280
    {
281
        return __(
282
            'facilitador::changes.admin_title', [
283
            'admin' => $this->getAdminLinkAttribute(),
284
            'action' => $this->getActionLabelAttribute(),
285
            'model' => $this->getModelNameHtmlAttribute(),
286
            'model_title' => $this->getLinkedTitleAttribute(),
287
            'date' => $this->getDateAttribute()
288
            ]
289
        );
290
    }
291
292
    /**
293
     * Get the admin name and link
294
     *
295
     * @return string HTML
296
     */
297
    public function getAdminLinkAttribute()
298
    {
299
        if ($this->changeable_id) {
0 ignored issues
show
The property changeable_id does not exist on object<Audit\Models\Change>. 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...
300
            return sprintf(
301
                '<a href="%s">%s</a>',
302
                $this->filterUrl(['changeable_id' => $this->changeable_id]),
0 ignored issues
show
The property changeable_id does not exist on object<Audit\Models\Change>. 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...
303
                $this->admin->getAdminTitleHtmlAttribute()
0 ignored issues
show
The property admin does not exist on object<Audit\Models\Change>. 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...
304
            );
305
        } else {
306
            return 'Someone';
307
        }
308
    }
309
310
    /**
311
     * Format the activity as a colored label
312
     *
313
     * @return string HTML
314
     */
315
    public function getActionLabelAttribute()
316
    {
317
        $map = [
318
            'created' => 'success',
319
            'updated' => 'warning',
320
            'deleted' => 'danger',
321
            'published' => 'info',
322
            'unpublished' => 'default',
323
        ];
324
325
        return sprintf(
326
            '<a href="%s" class="label label-%s">%s</a>',
327
            $this->filterUrl(['action' => $this->action]),
0 ignored issues
show
The property action does not exist on object<Audit\Models\Change>. 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...
328
            isset($map[$this->action]) ? $map[$this->action] : 'info',
0 ignored issues
show
The property action does not exist on object<Audit\Models\Change>. 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...
329
            __("facilitador::changes.actions.$this->action")
0 ignored issues
show
The property action does not exist on object<Audit\Models\Change>. 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...
330
        );
331
    }
332
333
    /**
334
     * Format the model name by translating it through the controllers's defined
335
     * title
336
     *
337
     * @return string HTML
338
     */
339
    public function getModelNameHtmlAttribute()
340
    {
341
        $class = Facilitador::controllerForModel($this->model);
0 ignored issues
show
The property model does not exist on object<Audit\Models\Change>. 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...
342
343
        // There is not a controller for the model
344
        if (!$class || !class_exists($class)) {
345
            return sprintf(
346
                '<b><a href="%s">%s</a></b>',
347
                $this->filterUrl(['model' => $this->model]),
0 ignored issues
show
The property model does not exist on object<Audit\Models\Change>. 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...
348
                preg_replace('#(?<!\ )[A-Z]#', ' $0', $this->model)
0 ignored issues
show
The property model does not exist on object<Audit\Models\Change>. 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...
349
            );
350
        }
351
352
        // There is a corresponding controller class
353
        $controller = new $class;
354
        return sprintf(
355
            '<b class="js-tooltip" title="%s"><a href="%s">%s</a></b>',
356
            htmlentities($controller->description()),
357
            $this->filterUrl(['model' => $this->model]),
0 ignored issues
show
The property model does not exist on object<Audit\Models\Change>. 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...
358
            Str::singular($controller->title())
359
        );
360
    }
361
362
    /**
363
     * Get the title of the model. Perhaps in the future there will be more smarts
364
     * here, like generating a link to the edit view
365
     *
366
     * @return string HTML
367
     */
368
    public function getLinkedTitleAttribute()
369
    {
370
        if (!$this->title) { return;
0 ignored issues
show
The property title does not exist on object<Audit\Models\Change>. 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...
371
        }
372
        return sprintf(
373
            '<a href="%s">"%s"</a>',
374
            $this->filterUrl(['model' => $this->model, 'key' => $this->key]),
0 ignored issues
show
The property model does not exist on object<Audit\Models\Change>. 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...
The property key does not exist on object<Audit\Models\Change>. 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...
375
            $this->title
0 ignored issues
show
The property title does not exist on object<Audit\Models\Change>. 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...
376
        );
377
    }
378
379
    /**
380
     * Get the date of the change
381
     *
382
     * @return string HTML
383
     */
384
    public function getDateAttribute()
385
    {
386
        \Carbon\Carbon::setLocale(Facilitador::locale());
387
        if (is_null($this->created_at)) {
0 ignored issues
show
The property created_at does not exist on object<Audit\Models\Change>. 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...
388
            return '-';
389
        }
390
391
        return sprintf(
392
            '<a href="%s" class="js-tooltip" title="%s">%s</a>',
393
            $this->filterUrl(['created_at' => $this->created_at->format('m/d/Y')]),
0 ignored issues
show
The property created_at does not exist on object<Audit\Models\Change>. 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...
394
            $this->getHumanDateAttribute(),
395
            $this->created_at->diffForHumans()
0 ignored issues
show
The property created_at does not exist on object<Audit\Models\Change>. 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...
396
        );
397
    }
398
399
    /**
400
     * Get the human readable date
401
     *
402
     * @return string
403
     */
404
    public function getHumanDateAttribute()
405
    {
406
        $format = __('pedreiro::changes.human_date');
407
        if (is_null($format)) {
408
            $format = 'd \d\e F \d\e Y \à\s h\hi';
409
        }
410
        
411
        if (is_null($this->created_at)) {
0 ignored issues
show
The property created_at does not exist on object<Audit\Models\Change>. 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...
412
            return '-';
413
        }
414
415
        return $this->created_at->format($format);
0 ignored issues
show
The property created_at does not exist on object<Audit\Models\Change>. 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...
416
    }
417
418
    /**
419
     * Customize the action links
420
     *
421
     * @param  array $data The data passed to a listing view
422
     * @return array
423
     */
424
    public function makeAdminActions($data)
0 ignored issues
show
The parameter $data is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
425
    {
426
        return array_filter(
427
            [
428
            $this->filter_action,
0 ignored issues
show
The property filter_action does not exist on object<Audit\Models\Change>. 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...
429
            $this->changes_action,
0 ignored issues
show
The property changes_action does not seem to exist. Did you mean changes?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
430
            $this->preview_action,
0 ignored issues
show
The property preview_action does not exist on object<Audit\Models\Change>. 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...
431
            ]
432
        );
433
    }
434
435
    /**
436
     * Make the preview filter icon
437
     *
438
     * @return string
439
     */
440
    public function getFilterActionAttribute()
441
    {
442
        return sprintf(
443
            '<a href="%s"
444
            class="glyphicon glyphicon-filter js-tooltip"
445
            title="' . __('pedreiro::changes.standard_list.filter') . '"
446
            data-placement="left"></a>',
447
            $this->filterUrl(['model' => $this->model, 'key' => $this->key]),
0 ignored issues
show
The property model does not exist on object<Audit\Models\Change>. 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...
The property key does not exist on object<Audit\Models\Change>. 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...
448
            strip_tags($this->getModelNameHtmlAttribute())
449
        );
450
    }
451
452
    /**
453
     * Make a link to filter the result set
454
     *
455
     * @return string
456
     */
457
    public function filterUrl($query)
458
    {
459
        return PedreiroURL::action('changes').'?'.Search::query($query);
460
    }
461
462
    /**
463
     * Make the changes icon
464
     *
465
     * @return string
466
     */
467
    public function getChangesActionAttribute()
468
    {
469
        // If there are changes, add the modal button
470
        if ($this->changed) {
0 ignored issues
show
The property changed does not exist on object<Audit\Models\Change>. 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...
471
            return sprintf(
472
                '<a href="%s"
473
                class="glyphicon glyphicon-export js-tooltip changes-modal-link"
474
                title="%s" data-placement="left"></a>',
475
                PedreiroURL::action('changes@edit', $this->id),
0 ignored issues
show
The property id does not exist on object<Audit\Models\Change>. 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...
476
                __('pedreiro::changes.standard_list.view')
477
            );
478
        }
479
480
        // Else, show a disabled button
481
        else {
482
            return sprintf(
483
                '<span
484
            class="glyphicon glyphicon-export js-tooltip"
485
            title="%s" data-placement="left"></span>', __('pedreiro::changes.standard_list.no_changed')
486
            );
487
        }
488
    }
489
490
    /**
491
     * Make link to preview a version as long as the model has a URI and the
492
     * action wasn't a delete action.
493
     *
494
     * @return string
495
     */
496
    public function getPreviewActionAttribute()
497
    {
498
        if ($this->changedModel
0 ignored issues
show
The property changedModel does not exist on object<Audit\Models\Change>. 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...
499
            && $this->changedModel->uri
0 ignored issues
show
The property changedModel does not exist on object<Audit\Models\Change>. 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...
500
            && $this->action != 'deleted'
0 ignored issues
show
The property action does not exist on object<Audit\Models\Change>. 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...
501
        ) {
502
            return sprintf(
503
                '<a href="%s" target="_blank"
504
                class="glyphicon glyphicon-bookmark js-tooltip"
505
                title="%s" data-placement="left"></a>',
506
                $this->preview_url,
0 ignored issues
show
The property preview_url does not exist on object<Audit\Models\Change>. 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...
507
                __('pedreiro::changes.standard_list.preview')
508
            );
509
        } else {
510
            return '<span class="glyphicon glyphicon-bookmark disabled"></span>';
511
        }
512
    }
513
514
    /**
515
     * Make the preview URL for a the model
516
     *
517
     * @return string
518
     */
519
    public function getPreviewUrlAttribute()
520
    {
521
        return vsprintf(
522
            '%s?%s=%s', [
523
            $this->changedModel->uri,
0 ignored issues
show
The property changedModel does not exist on object<Audit\Models\Change>. 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...
524
            static::QUERY_KEY,
525
            $this->id,
0 ignored issues
show
The property id does not exist on object<Audit\Models\Change>. 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...
526
            ]
527
        );
528
    }
529
530
    /**
531
     * Get just the attributes that should be displayed in the admin modal.
532
     *
533
     * @return array
534
     */
535
    public function attributesForModal()
536
    {
537
        // Remove some specific attributes.  Leaving empties in there so the updating
538
        // of values to NULL is displayed.
539
        $attributes = array_except(
540
            $this->changed, [
0 ignored issues
show
The property changed does not exist on object<Audit\Models\Change>. 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...
541
            'id', 'updated_at', 'created_at', 'password', 'remember_token',
542
            ]
543
        );
544
545
        // Make more readable titles
546
        $out = [];
547
        foreach ($attributes as $key => $val) {
548
            $out[Text::titleFromKey($key)] = $val;
549
        }
550
551
        return $out;
552
    }
553
}
554