<commit_before><?php

namespace gamringer\JSONPatch\Operation;

use gamringer\JSONPatch\Operation;
use gamringer\JSONPointer\Pointer;
use gamringer\JSONPointer;

class Remove extends Operation implements Atomic
{
    private $previousValue;
    
    public function __construct($path)
    {
        $this->path = $path;
    }

    public function apply(Pointer $target)
    {
        try {
            $this->previousValue = $target->remove($this->path);
        } catch (JSONPointer\Exception $e) {
            throw new Exception($e->getMessage(), null, $e);
        }
    }

    public function revert(Pointer $target)
    {
        if ($this->previousValue instanceof VoidValue) {
            return;
        }
        
        $target->insert($this->path, $this->previousValue);
    }

    public static function fromDecodedJSON($operationContent)
    {
        static::assertValidOperationContent($operationContent);

        return new static($operationContent->path);
    }

    private static function assertValidOperationContent($operationContent)
    {
        if (!property_exists($operationContent, 'path')) {
            throw new Operation\Exception('"Remove" Operations must contain a "path" member');
        }
    }
}<commit_msg>This code will never execute<commit_after><?php

namespace gamringer\JSONPatch\Operation;

use gamringer\JSONPatch\Operation;
use gamringer\JSONPointer\Pointer;
use gamringer\JSONPointer;

class Remove extends Operation implements Atomic
{
    private $previousValue;
    
    public function __construct($path)
    {
        $this->path = $path;
    }

    public function apply(Pointer $target)
    {
        try {
            $this->previousValue = $target->remove($this->path);
        } catch (JSONPointer\Exception $e) {
            throw new Exception($e->getMessage(), null, $e);
        }
    }

    public function revert(Pointer $target)
    {
        $target->insert($this->path, $this->previousValue);
    }

    public static function fromDecodedJSON($operationContent)
    {
        static::assertValidOperationContent($operationContent);

        return new static($operationContent->path);
    }

    private static function assertValidOperationContent($operationContent)
    {
        if (!property_exists($operationContent, 'path')) {
            throw new Operation\Exception('"Remove" Operations must contain a "path" member');
        }
    }
}
{'fraction_non_alphanumeric': 0.11023622047244094, 'fraction_numerical': 0.0, 'mean_word_length': 2.843949044585987, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6240843', 'n_tokens_mistral': 640, 'n_tokens_neox': 619, 'n_words': 143}