Completed
Push — master ( 724ebd...bb6c14 )
by Marcin
18s queued 11s
created

ArrayableConverter   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 16
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A convert() 0 5 1
1
<?php
2
3
namespace MarcinOrlowski\ResponseBuilder\Converters;
4
5
/**
6
 * Laravel API Response Builder
7
 *
8
 * @package   MarcinOrlowski\ResponseBuilder
9
 *
10
 * @author    Marcin Orlowski <mail (#) marcinOrlowski (.) com>
11
 * @copyright 2016-2019 Marcin Orlowski
12
 * @license   http://www.opensource.org/licenses/mit-license.php MIT
13
 * @link      https://github.com/MarcinOrlowski/laravel-api-response-builder
14
 */
15
16
use Illuminate\Contracts\Support\Arrayable;
17
use MarcinOrlowski\ResponseBuilder\Contracts\ConverterContract;
18
use MarcinOrlowski\ResponseBuilder\Validator;
19
20
class ArrayableConverter implements ConverterContract
21
{
22
    /**
23
     * Returns array representation of the object implementing Arrayable interface
24
     *
25
     * @param Arrayable $obj    Object to be converted
26
     * @param array     $config Converter config array to be used for this object (based on exact class
27
     *                          name match or inheritance).
28
     *
29
     * @return array
30
     */
31
    public function convert($obj, array /** @scrutinizer ignore-unused */ $config): array
32
    {
33
        Validator::assertInstanceOf('obj', $obj, Arrayable::class);
34
35
        return $obj->toArray();
36
    }
37
}
38