Code Duplication    Length = 17-17 lines in 2 locations

src/StreamFilters/InvariantFilter.php 2 locations

@@ 237-253 (lines=17) @@
234
            // Does this property even exist? If not, throw an exception
235
            if (!isset($this->' . ReservedKeywords::ATTRIBUTE_STORAGE . '[$name])) {';
236
237
        if ($hasParents) {
238
            $code .= 'return parent::__set($name, $value);';
239
        } else {
240
            $code .= 'if (property_exists($this, $name)) {' .
241
242
                ReservedKeywords::FAILURE_VARIABLE . '[] = "accessing $name in an invalid way";' .
243
                Placeholders::ENFORCEMENT . 'InvalidArgumentException' . Placeholders::PLACEHOLDER_CLOSE .
244
                '\AppserverIo\Doppelgaenger\ContractContext::close();
245
                return false;
246
                } else {' .
247
248
                ReservedKeywords::FAILURE_VARIABLE . '[] = "accessing $name as it does not exist";' .
249
                Placeholders::ENFORCEMENT . 'MissingPropertyException' . Placeholders::PLACEHOLDER_CLOSE .
250
                '\AppserverIo\Doppelgaenger\ContractContext::close();
251
                return false;
252
                }';
253
        }
254
255
        $code .= '}
256
        // Check if the invariant holds
@@ 332-348 (lines=17) @@
329
            // Does this property even exist? If not, throw an exception
330
            if (!isset($this->' . ReservedKeywords::ATTRIBUTE_STORAGE . '[$name])) {';
331
332
        if ($hasParents) {
333
            $code .= 'return parent::__get($name);';
334
        } else {
335
            $code .= 'if (property_exists($this, $name)) {' .
336
337
                ReservedKeywords::FAILURE_VARIABLE . '[] = "accessing $name in an invalid way";' .
338
                Placeholders::ENFORCEMENT . 'InvalidArgumentException' . Placeholders::PLACEHOLDER_CLOSE .
339
                '\AppserverIo\Doppelgaenger\ContractContext::close();
340
                return false;
341
                } else {' .
342
343
                ReservedKeywords::FAILURE_VARIABLE . '[] = "accessing $name as it does not exist";' .
344
                Placeholders::ENFORCEMENT . 'MissingPropertyException' . Placeholders::PLACEHOLDER_CLOSE .
345
                '\AppserverIo\Doppelgaenger\ContractContext::close();
346
                return false;
347
                }';
348
        }
349
350
        $code .= '}
351