JsonClassMetadataLoader   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 20
c 0
b 0
f 0
wmc 3
lcom 0
cbo 1
ccs 7
cts 7
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A loadFile() 0 14 3
1
<?php
2
3
/*
4
 * This file is part of the Ivory Serializer package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Ivory\Serializer\Mapping\Loader;
13
14
/**
15
 * @author GeLo <[email protected]>
16
 */
17
class JsonClassMetadataLoader extends AbstractFileClassMetadataLoader
18
{
19
    /**
20
     * {@inheritdoc}
21
     */
22 544
    protected function loadFile($file)
23
    {
24 544
        $data = @json_decode(@file_get_contents($file), true);
25
26 544
        if (json_last_error() !== JSON_ERROR_NONE) {
27 84
            throw new \InvalidArgumentException(json_last_error_msg());
28
        }
29
30 460
        if (!is_array($data)) {
31 4
            throw new \InvalidArgumentException(sprintf('The json mapping file "%s" is not valid.', $file));
32
        }
33
34 456
        return $data;
35
    }
36
}
37