Code Duplication    Length = 18-18 lines in 2 locations

src/JsonEncoder.php 1 location

@@ 610-627 (lines=18) @@
607
     * @throws \InvalidArgumentException If the depth is not an integer greater
608
     *                                   than or equal to zero.
609
     */
610
    public function setMaxDepth($maxDepth)
611
    {
612
        if (!is_int($maxDepth)) {
613
            throw new \InvalidArgumentException(sprintf(
614
                'The maximum depth should be an integer. Got: %s',
615
                is_object($maxDepth) ? get_class($maxDepth) : gettype($maxDepth)
616
            ));
617
        }
618
619
        if ($maxDepth < 1) {
620
            throw new \InvalidArgumentException(sprintf(
621
                'The maximum depth should 1 or greater. Got: %s',
622
                $maxDepth
623
            ));
624
        }
625
626
        $this->maxDepth = $maxDepth;
627
    }
628
}
629

src/JsonDecoder.php 1 location

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