Completed
Push — master ( 08635e...dd4786 )
by Nil
10:03
created

Mapper::buildMapping()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4286
cc 3
eloc 4
nc 4
nop 1
1
<?php
2
/**
3
 * Author: Nil Portugués Calderó <[email protected]>
4
 * Date: 10/16/15
5
 * Time: 8:59 PM.
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace NilPortugues\Laravel5\JsonApi\Mapper;
12
13
class Mapper extends \NilPortugues\Api\Mapping\Mapper
14
{
15
    /**
16
     * @param string|array $mappedClass
17
     *
18
     * @return array
19
     */
20
    protected function buildMapping($mappedClass)
21
    {
22
        return (\is_string($mappedClass) && \class_exists($mappedClass, true)) ?
23
            MappingFactory::fromClass($mappedClass) :
24
            MappingFactory::fromArray($mappedClass);
0 ignored issues
show
Bug introduced by
It seems like $mappedClass defined by parameter $mappedClass on line 20 can also be of type string; however, NilPortugues\Api\Mapping...ingFactory::fromArray() does only seem to accept array, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
25
    }
26
}
27