Code Duplication    Length = 15-17 lines in 3 locations

src/QueryResultParser.php 3 locations

@@ 37-51 (lines=15) @@
34
        
35
        $ref = new ReflectionClass($result);
36
        $methods = $ref->getMethods(ReflectionMethod::IS_PUBLIC);
37
        foreach ($methods as $method) {
38
            assert($method instanceof ReflectionMethod);
39
            
40
            if (substr($method->getName(), 0, 3) === 'set') {
41
                $propertyName = substr($method->getName(), 3);
42
                if ($propertyName === 'Meta') {
43
                    $result = $this->parseMeta($result, $json->meta);
44
                    continue;
45
                }
46
                if (property_exists($json, $propertyName)) {
47
                    $property = $json->$propertyName;
48
                    $method->invoke($result, $property);
49
                }
50
            }
51
        }
52
        
53
        $result = $this->parseRelatedTopics($result, $json->RelatedTopics);
54
        return $result;
@@ 63-79 (lines=17) @@
60
            $topic = new RelatedTopic();
61
            $ref = new ReflectionClass($topic);
62
            $methods = $ref->getMethods(ReflectionMethod::IS_PUBLIC);
63
            foreach ($methods as $method) {
64
                assert($method instanceof ReflectionMethod);
65
                
66
                if (substr($method->getName(), 0, 3) === 'set') {
67
                    $propertyName = substr($method->getName(), 3);
68
                    
69
                    if ($propertyName === 'Icon') {
70
                        $topic = $this->parseIcon($topic, $relatedTopic->Icon);
71
                        continue;
72
                    }
73
                    
74
                    if (property_exists($relatedTopic, $propertyName)) {
75
                        $property = $relatedTopic->$propertyName;
76
                        $method->invoke($topic, $property);
77
                    }
78
                }
79
            }
80
            $result->addRelatedTopic($topic);
81
        }
82
        
@@ 92-106 (lines=15) @@
89
        
90
        $ref = new ReflectionClass($ico);
91
        $methods = $ref->getMethods(ReflectionMethod::IS_PUBLIC);
92
        foreach ($methods as $method) {
93
            assert($method instanceof ReflectionMethod);
94
            
95
            if (substr($method->getName(), 0, 3) === 'set') {
96
                $propertyName = substr($method->getName(), 3);
97
                if (property_exists($icon, $propertyName)) {
98
                    $property = $icon->$propertyName;
99
                    
100
                    if ($propertyName === 'Height' || $propertyName === 'Width') {
101
                        $property = intval($property);
102
                    }
103
                    $method->invoke($ico, $property);
104
                }
105
            }
106
        }
107
        
108
        $topic->setIcon($ico);
109