Completed
Pull Request — master (#10)
by claudio
07:04
created

Caldav   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 2
c 4
b 0
f 0
lcom 0
cbo 1
dl 0
loc 32
ccs 0
cts 8
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A Calendar() 0 4 1
A Employee() 0 4 1
1
<?php
2
3
namespace plunner;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
class Caldav extends Model
8
{
9
    //TODO fillable and other fields
10
11
    /**
12
     * @var string
13
     */
14
    protected $primaryKey = 'calendar_id';
15
16
    /**
17
     * @var array
18
     */
19
    protected $touches = ['calendar'];
20
21
    /**
22
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
23
     */
24
    public function Calendar()
25
    {
26
        return $this->belongsTo(Calendar::class);
27
    }
28
29
    //TODO remmeber to don't allow to change timelsot for a caldav claendar
30
31
    /**
32
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
33
     */
34
    public function Employee()
35
    {
36
        $this->calendar->Employee();
0 ignored issues
show
Documentation introduced by
The property calendar does not exist on object<plunner\Caldav>. 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...
37
    }
38
}
39