Code Duplication    Length = 17-18 lines in 2 locations

src/Internal/JsonElementWriter.php 1 location

@@ 224-240 (lines=17) @@
221
     * @return JsonWritable
222
     * @throws \BadMethodCallException
223
     */
224
    public function writeNull(): JsonWritable
225
    {
226
        if ($this->topIsObjectStart()) {
227
            throw new BadMethodCallException('Cannot call writeNull() before name() during object serialization');
228
        }
229
230
        if ($this->serializeNull) {
231
            return $this->push(new JsonNull());
232
        }
233
234
        // if we're not serializing nulls
235
        if (null !== $this->pendingName) {
236
            $this->pendingName = null;
237
        }
238
239
        return $this;
240
    }
241
242
    /**
243
     * Sets whether nulls are serialized

src/Internal/JsonEncodeWriter.php 1 location

@@ 219-236 (lines=18) @@
216
     * @return JsonWritable
217
     * @throws \BadMethodCallException
218
     */
219
    public function writeNull(): JsonWritable
220
    {
221
        if ($this->topIsObjectStart()) {
222
            throw new BadMethodCallException('Cannot call writeNull() before name() during object serialization');
223
        }
224
225
        if ($this->serializeNull) {
226
            $null = null;
227
            return $this->push($null);
228
        }
229
230
        // if we're not serializing nulls
231
        if (null !== $this->pendingName) {
232
            $this->pendingName = null;
233
        }
234
235
        return $this;
236
    }
237
238
    /**
239
     * Sets whether nulls are serialized