Completed
Push — dev5 ( d45a54...be76cd )
by Ron
09:51
created

FileLinksCollection::toArray()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 7
c 1
b 0
f 0
nc 3
nop 1
dl 0
loc 16
rs 10
1
<?php
2
3
namespace App\Http\Resources;
4
5
use Carbon\Carbon;
6
use Illuminate\Http\Resources\Json\ResourceCollection;
7
8
class FileLinksCollection extends ResourceCollection
9
{
10
    /**
11
     * Transform the resource collection into an array.
12
     *
13
     * @param  \Illuminate\Http\Request  $request
14
     * @return array
15
     */
16
    public function toArray($request)
17
    {
18
        $collection = $this->collection;
19
        foreach($collection as $item)
20
        {
21
            if($item['expire'] < Carbon::now())
22
            {
23
                $item['expired'] = 1;
24
            }
25
            else
26
            {
27
                $item['expired'] = 0;
28
            }
29
        }
30
31
        return parent::toArray($collection);
0 ignored issues
show
Bug introduced by
$collection of type Illuminate\Support\Collection is incompatible with the type Illuminate\Http\Request expected by parameter $request of Illuminate\Http\Resource...ceCollection::toArray(). ( Ignorable by Annotation )

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

31
        return parent::toArray(/** @scrutinizer ignore-type */ $collection);
Loading history...
32
    }
33
}
34