Rs\Json\Patch\Document::patchOperationFactory PHP Method

patchOperationFactory() private method

private patchOperationFactory ( stdClass $possiblePatchOperation ) : Operation
$possiblePatchOperation stdClass
return Operation or null on unsupported patch operation
    private function patchOperationFactory(\stdClass $possiblePatchOperation)
    {
        if (!isset($possiblePatchOperation->op)) {
            $exceptionMessage = sprintf("No operation set for patch operation '%s'", json_encode($possiblePatchOperation));
            throw new InvalidOperationException($exceptionMessage);
        }
        switch ($possiblePatchOperation->op) {
            case 'add':
                if (!(($this->allowedPatchOperations & Add::APPLY) == Add::APPLY)) {
                    return null;
                }
                return new Add($possiblePatchOperation);
                break;
            case 'copy':
                if (!(($this->allowedPatchOperations & Copy::APPLY) == Copy::APPLY)) {
                    return null;
                }
                return new Copy($possiblePatchOperation);
                break;
            case 'move':
                if (!(($this->allowedPatchOperations & Move::APPLY) == Move::APPLY)) {
                    return null;
                }
                return new Move($possiblePatchOperation);
                break;
            case 'replace':
                if (!(($this->allowedPatchOperations & Replace::APPLY) == Replace::APPLY)) {
                    return null;
                }
                return new Replace($possiblePatchOperation);
                break;
            case 'remove':
                if (!(($this->allowedPatchOperations & Remove::APPLY) == Remove::APPLY)) {
                    return null;
                }
                return new Remove($possiblePatchOperation);
                break;
            case 'test':
                if (!(($this->allowedPatchOperations & Test::APPLY) == Test::APPLY)) {
                    return null;
                }
                return new Test($possiblePatchOperation);
                break;
            default:
                return null;
        }
    }