AccessReader   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 12
Bugs 1 Features 3
Metric Value
wmc 7
c 12
b 1
f 3
lcom 1
cbo 1
dl 0
loc 55
ccs 24
cts 24
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
C getAccessProperties() 0 37 7
1
<?php
2
3
namespace Accessible\Reader;
4
5
class AccessReader extends Reader
6
{
7
    /**
8
     * The name of the annotation class that define the properties access.
9
     *
10
     * @var string
11
     */
12
    private static $accessAnnotationClass = "Accessible\\Annotation\\Access";
13
14
    /**
15
     * Get a list of properties and the access that are given to them for given object.
16
     *
17
     * @param array  $properties The properties of the object to read.
18
     * @param Reader $annotationReader The annotation reader to use.
19
     *
20
     * @return array The list of properties and their access.
21
     */
22 7
    public static function getAccessProperties($properties, $annotationReader)
23
    {
24 7
        $objectAccessProperties = array();
25
26 7
        foreach ($properties as $propertyName => $property) {
27 7
            if (empty($objectAccessProperties[$propertyName])) {
28 7
                $objectAccessProperties[$propertyName] = array();
29 7
            }
30
31
            // Getters / Setters related annotations
32 7
            $propertyAccessAnnotation = $annotationReader->getPropertyAnnotation($property, self::$accessAnnotationClass);
0 ignored issues
show
Bug introduced by
The method getPropertyAnnotation() does not seem to exist on object<Accessible\Reader\Reader>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
33
34 7
            $accessProperties = array();
35 7
            if ($propertyAccessAnnotation !== null) {
36 7
                $accessProperties = $propertyAccessAnnotation->getAccessProperties();
37 7
            }
38
39
            // Collection related annotations
40 7
            $collectionAnnotation = null;
41 7
            foreach (self::$collectionAnnotationClasses as $annotationBehavior => $annotationClass) {
42 7
                $collectionAnnotation = $annotationReader->getPropertyAnnotation($property, $annotationClass);
0 ignored issues
show
Bug introduced by
The method getPropertyAnnotation() does not seem to exist on object<Accessible\Reader\Reader>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
43 7
                if ($collectionAnnotation !== null) {
44 6
                    break;
45
                }
46 7
            }
47
48 7
            $collectionMethods = array();
49 7
            if ($collectionAnnotation !== null) {
50 6
                $collectionMethods = $collectionAnnotation->getMethods();
51 6
            }
52
53
            // Merge and save the two arrays
54 7
            $objectAccessProperties[$propertyName] = array_merge($accessProperties, $collectionMethods);
55 7
        }
56
57 7
        return $objectAccessProperties;
58
    }
59
}
60