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

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