OrganizationObserver::creating()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 2
eloc 3
nc 2
nop 1
1
<?php
2
/**
3
 * @author  Renato Marinho <[email protected]>
4
 * @license http://opensource.org/licenses/GPL-3.0 GPLv3
5
 */
6
7
namespace GitScrum\Observers;
8
9
use GitScrum\Models\Organization;
10
use Auth;
11
12
class OrganizationObserver
13
{
14
    public function creating(Organization $organization)
15
    {
16
        if (!isset($organization->provider)) {
17
            $organization->provider = strtolower(Auth::user()->provider);
0 ignored issues
show
Documentation introduced by
The property provider does not exist on object<GitScrum\Models\Organization>. 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...
18
        }
19
    }
20
}
21