DoctrineMetadata   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 44
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B extract() 0 23 4
A hydrate() 0 4 1
1
<?php
2
/**
3
 * Sake
4
 *
5
 * @link      http://github.com/sandrokeil/CodeGenerator for the canonical source repository
6
 * @copyright Copyright (c) 2014 Sandro Keil
7
 * @license   http://github.com/sandrokeil/CodeGenerator/blob/master/LICENSE.txt New BSD License
8
 */
9
10
namespace Sake\CodeGenerator\Hydrator;
11
12
use \Doctrine\ORM\Mapping\ClassMetadataInfo;
13
use Zend\Stdlib\Hydrator\HydratorInterface;
14
use Sake\CodeGenerator\Exception;
15
16
/**
17
 * Doctrine meta data hydrator
18
 *
19
 * Hydrates doctrine meta data for our generator meta data object
20
 */
21
class DoctrineMetadata implements HydratorInterface
22
{
23
    /**
24
     * Extract values from an object
25
     *
26
     * @param  object $object
27
     * @return array
28
     */
29
    public function extract($object)
30
    {
31
        if (!$object instanceof ClassMetadataInfo) {
0 ignored issues
show
Bug introduced by
The class Doctrine\ORM\Mapping\ClassMetadataInfo does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
32
            return array();
33
        }
34
35
        $mapped = array(
36
            'columns' => array(),
37
            'foreignKeys' => array()
38
        );
39
40
        $mapped['name'] = $object->name;
41
        $mapped['table'] = $object->table;
42
43
        foreach ($object->fieldMappings as $name => $data) {
44
            $mapped['columns'][$name] = $data;
45
        }
46
        foreach ($object->associationMappings as $name => $data) {
47
            $mapped['foreignKeys'][$name] = $data;
48
        }
49
50
        return $mapped;
51
    }
52
53
    /**
54
     * Hydrate $object with the provided $data.
55
     *
56
     * @param  array $data
57
     * @param  object $object
58
     * @return object
59
     */
60
    public function hydrate(array $data, $object)
61
    {
62
        throw new Exception\RuntimeException('Hydration is not implemented yet');
63
    }
64
}
65