Completed
Push — master ( 739412...8758f6 )
by Phecho
03:45
created

Group   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 5
Bugs 1 Features 3
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 26
rs 10
c 5
b 1
f 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A scopeIsGroup() 0 4 1
A getUrlAttribute() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of Gitamin.
5
 * 
6
 * Copyright (C) 2015-2016 The Gitamin Team
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Gitamin\Models;
13
14
class Group extends Owner
15
{
16
    protected $table = 'owners';
17
18
    /**
19
     * Finds all groups.
20
     *
21
     * @param \Illuminate\Database\Eloquent\Builder $query
22
     *
23
     * @return \Illuminate\Database\Eloquent\Builder
24
     */
25
    public function scopeIsGroup($query)
26
    {
27
        return $query->where('type', 'Group');
28
    }
29
30
    /**
31
     * Returns group route.
32
     *
33
     * @return string
34
     */
35
    public function getUrlAttribute()
36
    {
37
        return route('groups.group_show', ['owner' => $this->path]);
0 ignored issues
show
Documentation introduced by
The property path does not exist on object<Gitamin\Models\Group>. 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...
38
    }
39
}
40