Code Duplication    Length = 21-21 lines in 2 locations

src/Array2Object.php 1 location

@@ 116-136 (lines=21) @@
113
     *
114
     * @return array|bool|float|int|string
115
     */
116
    private function parseValue($value, $types, \ReflectionProperty $property, $object)
117
    {
118
        foreach ($types as $type) {
119
120
            foreach ($this->context->getParsers() as $parser) {
121
                if ($parser instanceof ValueParserInterface) {
122
                    if (is_array($value) && strpos($type, '[]') !== false) {
123
                        foreach ($value as $key => &$arrayValue) {
124
                            $arrayValue = $parser->toObjectValue($arrayValue, str_replace('[]', null, $type), $property, $object);
125
                        }
126
                    } else {
127
                        $value = $parser->toObjectValue($value, $type, $property, $object);
128
                    }
129
                } else {
130
                    throw new \InvalidArgumentException(sprintf("%s is not a valid parser.", get_class($parser)));
131
                }
132
            }
133
        }
134
135
        return $value;
136
    }
137
}

src/Object2Array.php 1 location

@@ 92-112 (lines=21) @@
89
     *
90
     * @return array|bool|float|int|string
91
     */
92
    private function parseValue($value, $types, \ReflectionProperty $property, $object)
93
    {
94
        foreach ($types as $type) {
95
            foreach ($this->context->getParsers() as $parser) {
96
                if ($parser instanceof ValueParserInterface) {
97
                    if (is_array($value) && strpos($type, '[]') !== false) {
98
                        foreach ($value as $key => &$arrayValue) {
99
                            $arrayValue = $parser->toArrayValue($arrayValue, str_replace('[]', null, $type), $property, $arrayValue);
100
                        }
101
                    } else {
102
                        //print_r($value);
103
                        $value = $parser->toArrayValue($value, $type, $property, $object);
104
                    }
105
                } else {
106
                    throw new \InvalidArgumentException(sprintf("%s is not a valid parser.", get_class($parser)));
107
                }
108
            }
109
        }
110
111
        return $value;
112
    }
113
}