Completed
Push — master ( 8a8686...f224a8 )
by Ruben
01:10
created

HasMeta::meta()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Spatie\LaravelResourceEndpoints;
4
5
/** @mixin \Illuminate\Http\Resources\Json\JsonResource */
6
trait HasMeta
7
{
8 View Code Duplication
    public static function collection($resource)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
9
    {
10
        $meta = self::meta();
11
12
        if (! count($meta)) {
13
            parent::collection($resource);
14
        }
15
16
        return parent::collection($resource)->additional([
17
            'meta' => $meta,
18
        ]);
19
    }
20
21 View Code Duplication
    public static function make(...$parameters)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
22
    {
23
        $meta = self::meta();
24
25
        if (! count($meta)) {
26
            parent::make(...$parameters);
27
        }
28
29
        return parent::make(...$parameters)->additional([
30
            'meta' => $meta,
31
        ]);
32
    }
33
34
    public static function meta()
35
    {
36
        return [];
37
    }
38
}
39