Completed
Push — master ( f91fe8...410c26 )
by Quim González
03:25
created

AsksForTasks   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 13
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A askForTasks() 0 6 1
1
<?php
2
3
namespace App\Http\Requests\Traits;
4
use App\Task;
5
6
7
/**
8
 * Trait ChecksPermissions.
9
 */
10
trait AsksForTasks
11
{
12
13
    /**
14
     * @param $task
15
     * @return mixed
16
     */
17
    protected function askForTasks()
18
    {
19
        $tasks = Task::all();
20
        $task_names = $tasks->pluck('name')->toArray();
21
        $task_name = $this->choice('Task id?', $task_names);
0 ignored issues
show
Bug introduced by
It seems like choice() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

21
        /** @scrutinizer ignore-call */ 
22
        $task_name = $this->choice('Task id?', $task_names);
Loading history...
22
        return $tasks->where('name', $task_name)->first()->id;
23
24
    }
25
26
}
27