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

Calendar::timeslots()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace plunner;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
/**
8
 * Class Calendar
9
 *
10
 * @package plunner
11
 * @author Claudio Cardinale <[email protected]>
12
 * @copyright 2015 Claudio Cardinale
13
 * @version 1.0.0
14
 * @property integer $id
15
 * @property string $name
16
 * @property integer $employee_id
17
 * @property \Carbon\Carbon $created_at
18
 * @property \Carbon\Carbon $updated_at
19
 * @property-read \plunner\Employee $employees
20
 * @property-read \Illuminate\Database\Eloquent\Collection|\plunner\Timeslot[] $timeslots
21
 * @method static \Illuminate\Database\Query\Builder|\plunner\Calendar whereId($value)
22
 * @method static \Illuminate\Database\Query\Builder|\plunner\Calendar whereName($value)
23
 * @method static \Illuminate\Database\Query\Builder|\plunner\Calendar whereEmployeeId($value)
24
 * @method static \Illuminate\Database\Query\Builder|\plunner\Calendar whereCreatedAt($value)
25
 * @method static \Illuminate\Database\Query\Builder|\plunner\Calendar whereUpdatedAt($value)
26
 */
27
class Calendar extends Model
28
{
29
    /**
30
     * The attributes that are mass assignable.
31
     *
32
     * @var array
33
     */
34
    protected $fillable = ['name'];
35
36
    /**
37
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
38
     */
39
    public function employee()
40
    {
41
        return $this->belongsTo('plunner\Employee');
42
    }
43
44
    /**
45
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
46
     */
47
    public function timeslots()
48
    {
49
        return $this->hasMany('plunner\Timeslot');
50
    }
51
52
    /**
53
     * @return \Illuminate\Database\Eloquent\Relations\HasOne|null
54
     */
55
    public function Caldav()
56
    {
57
        if($this->type == 'caldav')
0 ignored issues
show
Documentation introduced by
The property type does not exist on object<plunner\Calendar>. 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...
58
            return $this->hasOne(Caldav::class);
59
        return null;
60
    }
61
}
62