Completed
Branch job-vuejs (8df734)
by Adam
17:32
created

FirmWithBenefits::transform()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 1
nop 1
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Coyote\Http\Transformers;
4
5
use Coyote\Firm;
6
use League\Fractal\TransformerAbstract;
7
8
class FirmWithBenefits extends TransformerAbstract
9
{
10
    /**
11
     * @param Firm $firm
12
     * @return array
13
     */
14
    public function transform(Firm $firm): array
15
    {
16
        $data = array_except($firm->toArray(), ['benefits']);
17
18
        return array_merge($data, [
19
            'thumbnail' => $firm->logo->getFilename() ? (string) $firm->logo->url() : cdn('img/logo-gray.png'),
20
            'logo' => $firm->getOriginal('logo'),
21
            'benefits' => $firm->benefits->pluck('name')->toArray()
0 ignored issues
show
Bug introduced by
The method pluck cannot be called on $firm->benefits (of type array<integer,object<Coyote\Firm\Benefit>>).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
22
        ]);
23
    }
24
}
25