TafsirCollection   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 18
ccs 11
cts 11
cp 1
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A fromResponse() 0 13 1
1
<?php
2
3
namespace Ianrizky\MoslemPray\Response\MyQuran\Collection;
4
5
use Ianrizky\MoslemPray\Contracts\Response\Responsable;
6
use Ianrizky\MoslemPray\Response\MyQuran\Tafsir;
7
use Illuminate\Http\Client\Response;
8
use Spatie\DataTransferObject\DataTransferObjectCollection;
9
10
/**
11
 * @method \Ianrizky\MoslemPray\Response\MyQuran\Tafsir current()
12
 */
13
class TafsirCollection extends DataTransferObjectCollection implements Responsable
14
{
15
    /**
16
     * {@inheritDoc}
17
     */
18 1
    public static function fromResponse(Response $response)
19
    {
20 1
        return new static(array_map(function ($entity) {
21 1
            return new Tafsir([
22 1
                'id' => $entity['tafsir_id'],
23 1
                'name' => $entity['aya_name'],
24 1
                'surat_number' => $entity['sura_id'],
25 1
                'ayat_number' => $entity['aya_number'],
26 1
                'mufasir' => $entity['mufasir'],
27 1
                'text' => $entity['text'],
28 1
                'html' => $entity['html'] ?? null,
29
            ]);
30 1
        }, data_get($response->json(), 'data', [])));
31
    }
32
}
33