AsksForTasks::askForTasks()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 2
b 0
f 0
nc 1
nop 0
dl 0
loc 12
rs 9.4285
1
<?php
2
3
namespace App\Http\Requests\Traits;
4
5
use App\Task;
6
7
/**
8
 * Trait ChecksPermissions.
9
 */
10
trait AsksForTasks
11
{
12
    /**
13
     * @param $task
14
     *
15
     * @return mixed
16
     */
17
    protected function askForTasks()
18
    {
19
        $tasks = Task::all();
20
21
        //pluck és com si es fes un foreach buscant per nom i afegir-ho a un array.
22
        //el que fa es agafar el valor a partir d'una clau.
23
        // ho passem a array i ho mostrem.
24
        // + info README
25
        $task_names = $tasks->pluck('name')->toArray();
26
        $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

26
        /** @scrutinizer ignore-call */ 
27
        $task_name = $this->choice('Task id?', $task_names);
Loading history...
27
28
        return $tasks->where('name', $task_name)->first()->id;
29
    }
30
}
31