Image   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 26
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 16 2
1
<?php
2
3
namespace Faithgen\Discussions\Http\Resources;
4
5
use FaithGen\SDK\Helpers\ImageHelper;
6
use Illuminate\Http\Resources\Json\JsonResource;
7
use Illuminate\Support\Str;
8
use InnoFlash\LaraStart\Helper;
9
10
class Image extends JsonResource
11
{
12
    /**
13
     * Transform the resource into an array.
14
     *
15
     * @param  \Illuminate\Http\Request  $request
16
     *
17
     * @return array
18
     */
19
    public function toArray($request)
20
    {
21
        if (Str::of($this->imageable->discussable_type)->contains('Ministry')) {
22
            $server = config('faithgen-sdk.ministries-server');
23
        } else {
24
            $server = config('faithgen-sdk.users-server-server');
25
        }
26
27
        return [
28
            'id'       => $this->id,
29
            'caption'  => $this->caption,
30
            'comments' => $this->comments()->count(),
31
            'avatar'   => ImageHelper::getImage('discussions', $this->resource, $server),
32
            'date'     => Helper::getDates($this->created_at),
33
        ];
34
    }
35
}
36