Completed
Push — master ( bb6c14...7b9d4f )
by Marcin
23s queued 11s
created

ToArrayConverter::convert()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 2
b 0
f 0
nc 1
nop 2
dl 0
loc 5
rs 10
1
<?php
2
declare(strict_types=1);
3
4
namespace MarcinOrlowski\ResponseBuilder\Converters;
5
6
/**
7
 * Laravel API Response Builder
8
 *
9
 * @package   MarcinOrlowski\ResponseBuilder
10
 *
11
 * @author    Marcin Orlowski <mail (#) marcinOrlowski (.) com>
12
 * @copyright 2016-2019 Marcin Orlowski
13
 * @license   http://www.opensource.org/licenses/mit-license.php MIT
14
 * @link      https://github.com/MarcinOrlowski/laravel-api-response-builder
15
 */
16
17
use MarcinOrlowski\ResponseBuilder\Contracts\ConverterContract;
18
use MarcinOrlowski\ResponseBuilder\Validator;
19
20
class ToArrayConverter implements ConverterContract
21
{
22
    /**
23
     * Returns array representation of the object.
24
     *
25
     * @param object $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::assertIsObject('obj', $obj);
34
35
        return $obj->toArray();
36
    }
37
}
38