Code Duplication    Length = 18-18 lines in 2 locations

src/JsonDecoder.php 1 location

@@ 230-247 (lines=18) @@
227
     * @throws \InvalidArgumentException If the depth is not an integer greater
228
     *                                   than or equal to zero
229
     */
230
    public function setMaxDepth($maxDepth)
231
    {
232
        if (!is_int($maxDepth)) {
233
            throw new \InvalidArgumentException(sprintf(
234
                'The maximum depth should be an integer. Got: %s',
235
                is_object($maxDepth) ? get_class($maxDepth) : gettype($maxDepth)
236
            ));
237
        }
238
239
        if ($maxDepth < 1) {
240
            throw new \InvalidArgumentException(sprintf(
241
                'The maximum depth should 1 or greater. Got: %s',
242
                $maxDepth
243
            ));
244
        }
245
246
        $this->maxDepth = $maxDepth;
247
    }
248
249
    /**
250
     * Returns the decoding of JSON objects.

src/JsonEncoder.php 1 location

@@ 629-646 (lines=18) @@
626
     * @throws \InvalidArgumentException If the depth is not an integer greater
627
     *                                   than or equal to zero
628
     */
629
    public function setMaxDepth($maxDepth)
630
    {
631
        if (!is_int($maxDepth)) {
632
            throw new \InvalidArgumentException(sprintf(
633
                'The maximum depth should be an integer. Got: %s',
634
                is_object($maxDepth) ? get_class($maxDepth) : gettype($maxDepth)
635
            ));
636
        }
637
638
        if ($maxDepth < 1) {
639
            throw new \InvalidArgumentException(sprintf(
640
                'The maximum depth should 1 or greater. Got: %s',
641
                $maxDepth
642
            ));
643
        }
644
645
        $this->maxDepth = $maxDepth;
646
    }
647
}
648