Completed
Push — master ( 3a53f1...4212b8 )
by Renato
08:23
created

Sprint   B

Complexity

Total Complexity 42

Size/Duplication

Total Lines 282
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 42
lcom 2
cbo 4
dl 0
loc 282
rs 8.295
c 1
b 0
f 0

27 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 4 1
A productBacklog() 0 4 1
A branches() 0 4 1
A issues() 0 5 1
A comments() 0 5 1
A attachments() 0 4 1
A notes() 0 5 1
A favorite() 0 4 1
A status() 0 4 1
A pullrequests() 0 12 2
A totalAdditions() 0 10 1
A totalPullRequests() 0 8 1
B workingDays() 0 22 5
A weeks() 0 7 2
A getPSR2Errors() 0 14 1
A getEffort() 0 6 1
A avgEffort() 0 6 1
A issueTypes() 0 15 1
A issueStatus() 0 8 1
A getVisibilityAttribute() 0 4 2
A getSlugAttribute() 0 4 2
A issuesHasUsers() 0 10 1
A getPercentComplete() 0 7 2
A notesPercentComplete() 0 7 2
B burdown() 0 22 4
A activities() 0 13 1
A getTimeboxAttribute() 0 8 3

How to fix   Complexity   

Complex Class

Complex classes like Sprint often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use Sprint, and based on these observations, apply Extract Interface, too.

1
<?php
2
/**
3
 * GitScrum v0.1.
4
 *
5
 * @author  Renato Marinho <[email protected]>
6
 * @license http://opensource.org/licenses/GPL-3.0 GPLv3
7
 */
8
namespace GitScrum\Models;
9
10
use Illuminate\Database\Eloquent\Model;
11
use Illuminate\Database\Eloquent\SoftDeletes;
12
use Carbon\Carbon;
13
use GitScrum\Classes\Helper;
14
15
class Sprint extends Model
16
{
17
    use SoftDeletes;
18
19
    /**
20
     * The database table used by the model.
21
     *
22
     * @var string
23
     */
24
    protected $table = 'sprints';
25
26
    /**
27
     * Attributes that should be mass-assignable.
28
     *
29
     * @var array
30
     */
31
    protected $fillable = ['user_id', 'product_backlog_id', 'slug', 'title', 'description', 'version',
32
        'is_private', 'date_start', 'date_finish', 'state', 'color', 'position', 'closed_at', ];
33
34
    /**
35
     * The attributes excluded from the model's JSON form.
36
     *
37
     * @var array
38
     */
39
    protected $hidden = [];
40
41
    /**
42
     * The attributes that should be casted to native types.
43
     *
44
     * @var array
45
     */
46
    protected $casts = [];
47
48
    protected static function boot()
49
    {
50
        parent::boot();
51
    }
52
53
    public function productBacklog()
54
    {
55
        return $this->belongsTo(\GitScrum\Models\ProductBacklog::class, 'product_backlog_id', 'id');
56
    }
57
58
    public function branches()
59
    {
60
        return $this->hasMany(\GitScrum\Models\Branch::class, 'sprint_id', 'id');
61
    }
62
63
    public function issues()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
64
    {
65
        return $this->hasMany(\GitScrum\Models\Issue::class, 'sprint_id', 'id')
66
            ->orderby('position', 'ASC');
67
    }
68
69
    public function issuesHasUsers()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
70
    {
71
        $users = $this->issues->map(function ($issue) {
0 ignored issues
show
Documentation introduced by
The property issues does not exist on object<GitScrum\Models\Sprint>. 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...
72
            return $issue->users;
73
        })->reject(function ($value) {
74
            return $value == null;
75
        })->flatten(1)->unique('id')->splice(0, 3);
76
77
        return $users->all();
78
    }
79
80
    public function comments()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
81
    {
82
        return $this->morphMany(\GitScrum\Models\Comment::class, 'commentable')
83
            ->orderby('created_at', 'DESC');
84
    }
85
86
    public function attachments()
87
    {
88
        return $this->morphMany(\GitScrum\Models\Attachment::class, 'attachmentable');
89
    }
90
91
    public function notes()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
92
    {
93
        return $this->morphMany(\GitScrum\Models\Note::class, 'noteable')
94
            ->orderby('position', 'ASC');
95
    }
96
97
    public function favorite()
98
    {
99
        return $this->morphOne(\GitScrum\Models\Favorite::class, 'favoriteable');
100
    }
101
102
    public function status()
103
    {
104
        return $this->hasOne(\GitScrum\Models\ConfigStatus::class, 'id', 'config_status_id');
105
    }
106
107
    public function pullrequests()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
108
    {
109
        $prs = $this->branches->map(function ($branch) {
0 ignored issues
show
Documentation introduced by
The property branches does not exist on object<GitScrum\Models\Sprint>. 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...
110
            if ($branch->pullrequests->count()) {
111
                return $branch->pullrequests;
112
            }
113
        })->reject(function ($value) {
114
            return $value == null;
115
        });
116
117
        return $prs->all();
118
    }
119
120
    public function getPercentComplete()
121
    {
122
        $total = $this->issues->count();
0 ignored issues
show
Documentation introduced by
The property issues does not exist on object<GitScrum\Models\Sprint>. 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...
123
        $totalClosed = $total - $this->issues->where('closed_at', null)->count();
0 ignored issues
show
Documentation introduced by
The property issues does not exist on object<GitScrum\Models\Sprint>. 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...
124
125
        return ($totalClosed) ? ceil(($totalClosed * 100) / $total) : 0;
126
    }
127
128
    public function notesPercentComplete()
129
    {
130
        $total = $this->notes->count();
0 ignored issues
show
Documentation introduced by
The property notes does not exist on object<GitScrum\Models\Sprint>. 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...
131
        $totalClosed = $total - $this->notes->where('completed_at', null)->count();
0 ignored issues
show
Documentation introduced by
The property notes does not exist on object<GitScrum\Models\Sprint>. 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...
132
133
        return ($totalClosed) ? ceil(($totalClosed * 100) / $total) : 0;
134
    }
135
136
    public function totalAdditions()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
137
    {
138
        $additions = $this->branches->map(function ($branch) {
0 ignored issues
show
Documentation introduced by
The property branches does not exist on object<GitScrum\Models\Sprint>. 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...
139
            return $branch->commits;
140
        })->flatten(1)->map(function ($commit) {
141
            return $commit->files;
142
        })->flatten(1)->sum('additions');
143
144
        return $additions;
145
    }
146
147
    public function totalPullRequests()
148
    {
149
        $prs = $this->branches->map(function ($branch) {
0 ignored issues
show
Documentation introduced by
The property branches does not exist on object<GitScrum\Models\Sprint>. 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...
150
            return $branch->pullrequests()->count();
151
        });
152
153
        return array_sum($prs->all());
154
    }
155
156
    public function workingDays($start = null)
157
    {
158
        $begin = strtotime(is_null($start) ? $this->attributes['date_start'] : $start);
159
        $end = strtotime($this->attributes['date_finish']);
160
        if ($begin > $end) {
161
            return 0;
162
        } else {
163
            $no_days = 0;
164
            $weekends = 0;
165
            while ($begin <= $end) {
166
                ++$no_days;
167
                $what_day = date('N', $begin);
168
                if ($what_day > 5) {
169
                    ++$weekends;
170
                }
171
                $begin += 86400;
172
            }
173
            $working_days = $no_days - $weekends;
174
175
            return $working_days;
176
        }
177
    }
178
179
    public function weeks($start = null)
180
    {
181
        $begin = Carbon::parse(is_null($start) ? $this->attributes['date_start'] : $start);
182
        $end = Carbon::parse($this->attributes['date_finish']);
183
184
        return round($begin->diffInDays($end) / 7);
185
    }
186
187
    public function getPSR2Errors()
188
    {
189
        $errors = 0;
190
        /*
191
        foreach ($this->branches as $branch) {
192
            foreach ($branch->commits as $commit) {
193
                foreach ($commit->files as $file) {
194
                    $errors += $file->filePhpcs->count();
195
                }
196
            }
197
        }
198
        */
199
        return $errors;
200
    }
201
202
    public function getEffort()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
203
    {
204
        $effort = $this->issues->sum('effort');
0 ignored issues
show
Documentation introduced by
The property issues does not exist on object<GitScrum\Models\Sprint>. 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...
205
206
        return $effort;
207
    }
208
209
    public function avgEffort()
210
    {
211
        $effort = round($this->issues->avg('effort'), 2);
0 ignored issues
show
Documentation introduced by
The property issues does not exist on object<GitScrum\Models\Sprint>. 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...
212
213
        return $effort;
214
    }
215
216
    public function burdown()
217
    {
218
        $helper = new Helper();
219
        $total = $this->issues->count();
0 ignored issues
show
Documentation introduced by
The property issues does not exist on object<GitScrum\Models\Sprint>. 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...
220
        $finished = (Carbon::now() > $this->attributes['date_finish']) ? Carbon::now() : $this->attributes['date_finish'];
221
        $finished = (is_null($this->attributes['closed_at'])) ? $finished : $this->attributes['closed_at'];
222
223
        $dates = $helper->arrayDateRange([$this->attributes['date_start'], $finished], $total);
224
225
        $previous = $this->attributes['date_start'];
226
        $arr = [];
227
        $arr[$previous] = $total;
228
229
        foreach ($dates as $date => $value) {
230
            $closed = $this->issues()->whereDate('closed_at', '=', $date)->count();
231
            $totalPrevious = $total - $arr[$previous];
232
            $arr[$date] = $total - ($closed + $totalPrevious);
233
            $previous = $date;
234
        }
235
236
        return $arr;
237
    }
238
239
    public function activities()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
240
    {
241
        $activities = $this->issues()
242
            ->with('statuses')->get()->map(function ($issue) {
243
                return $issue->statuses;
244
            })->flatten(1)->map(function ($statuses) {
245
                return $statuses;
246
            })->sortByDesc('created_at');
247
248
        $activities->splice(15);
249
250
        return $activities->all();
251
    }
252
253
    public function issueTypes()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
254
    {
255
        $types = $this->issues->map(function ($issue) {
0 ignored issues
show
Documentation introduced by
The property issues does not exist on object<GitScrum\Models\Sprint>. 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...
256
            return $issue->type;
257
        })->groupBy('slug')->map(function ($type) {
258
            return [
259
                'sprint' => $this->slug,
0 ignored issues
show
Documentation introduced by
The property slug does not exist on object<GitScrum\Models\Sprint>. 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...
260
                'slug' => $type->first()->slug,
261
                'title' => $type->first()->title,
262
                'color' => $type->first()->color,
263
                'total' => $type->count(), ];
264
        })->sortByDesc('total')->all();
265
266
        return $types;
267
    }
268
269
    public function issueStatus()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
270
    {
271
        $status = $this->issues->map(function ($issue) {
0 ignored issues
show
Documentation introduced by
The property issues does not exist on object<GitScrum\Models\Sprint>. 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...
272
            return $issue->status;
273
        })->groupBy('slug')->all();
274
275
        return $status;
276
    }
277
278
    public function getVisibilityAttribute()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
279
    {
280
        return $this->attributes['is_private'] ? _('Private') : _('Public');
281
    }
282
283
    public function getSlugAttribute()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
284
    {
285
        return isset($this->attributes['slug']) ? $this->attributes['slug'] : '';
286
    }
287
288
    public function getTimeboxAttribute()
289
    {
290
        $date_start = isset($this->attributes['date_start']) ?
291
            Carbon::parse($this->attributes['date_start'])->toDateString() : '';
292
        $date_finish = isset($this->attributes['date_finish']) ?
293
            Carbon::parse($this->attributes['date_finish'])->toDateString() : '';
294
        return $date_start . ' ' . _('to') . ' ' . $date_finish;
295
    }
296
}
297