@param PbjxEvent $pbjxEvent

@return Node

@throws \Throwable
358932
protected function getNode(PbjxEvent $pbjxEvent): Node
    {
        /** @var Command $command */
        $command = $pbjxEvent->getMessage();
        Assertion::true($command->has('node_ref'), 'Field "node_ref" is required.', 'node_ref');

        /** @var NodeRef $nodeRef */
        $nodeRef = $command->get('node_ref');
        $pbjx = $pbjxEvent::getPbjx();

        try {
            $request = $this->createGetNodeRequest($command, $nodeRef, $pbjx)
                ->set('consistent_read', true)
                ->set('node_ref', $nodeRef)
                ->set('qname', $nodeRef->getQName()->toString());

            $response = $pbjx->copyContext($command, $request)->request($request);
        } catch (RequestHandlingFailed $e) {
            if (Code::NOT_FOUND === $e->getResponse()->get('error_code')) {
                throw NodeNotFound::forNodeRef($nodeRef, $e);
            }

            throw $e;
        } catch (\Throwable $e) {
            throw $e;
        }

        $expectedEtag = $command->get('expected_etag');
        if (null !== $expectedEtag && $expectedEtag !== $response->get('node')->get('etag')) {
            throw new OptimisticCheckFailed(
                sprintf('NodeRef [%s] did not have expected etag [%s].', $nodeRef, $expectedEtag)
            );
        }

        return $response->get('node')->freeze();
    }
332066
protected function ensureSlugIsAvailable(PbjxEvent $pbjxEvent, NodeRef $nodeRef, string $slug): void
    {
        $pbjx = $pbjxEvent::getPbjx();
        $command = $pbjxEvent->getMessage();

        try {
            $request = $this->createGetNodeRequest($command, $nodeRef, $pbjx)
                ->set('consistent_read', true)
                ->set('qname', $nodeRef->getQName()->toString())
                ->set('slug', $slug);

            $response = $pbjx->copyContext($command, $request)->request($request);
        } catch (RequestHandlingFailed $e) {
            if (Code::NOT_FOUND === $e->getResponse()->get('error_code')) {
                // this is what we want
                return;
            }

            throw $e;
        } catch (\Throwable $t) {
            throw $t;
        }

        /** @var Node $node */
        $node = $response->get('node');

        if ($nodeRef->getId() === (string)$node->get('_id')) {
            // this is the same node.
            return;
        }

        throw new NodeAlreadyExists(
            sprintf(
                'The [%s] with slug [%s] already exists so [%s] cannot continue.',
                $node::schema()->getCurie()->getMessage(),
                $slug,
                $command->generateMessageRef()
            )
        );
    }
1338280
protected function applyEventCdbXmlFromUDB2(
        $eventId,
        $cdbXmlNamespaceUri,
        $cdbXml
    ) {
        $document = $this->newDocument($eventId);

        $eventLd = $this->projectEventCdbXmlToObject(
            $document->getBody(),
            $eventId,
            $cdbXmlNamespaceUri,
            $cdbXml
        );

        return $document->withBody($eventLd);
    }
184935
private function addChainNode()
    {
        $builder = new TreeBuilder('chain');
        $node    = $this->getRootNode($builder, 'chain');

        $node
            ->fixXmlConfig('provider')
            ->children()
                ->arrayNode('providers')
                    ->prototype('scalar')->end()
                ->end()
            ->end()
        ;

        return $node;
    }
1072742
protected function createGetAllAppsResponse(GetAllAppsRequest $request, Pbjx $pbjx): GetAllAppsResponse
    {
        /** @var GetAllAppsResponse $response */
        $response = $this->createResponseFromRequest($request, $pbjx);
        return $response;
    }
620155
public function parse(Token $token): Node
    {
        $stream = $this->parser->getStream();

        $stream->expect(Token::BLOCK_END_TYPE);

        $body = $this->parser->subparse(function (Token $token): bool {
            return $token->test('endoptional');
        }, true);

        $stream->expect(Token::BLOCK_END_TYPE);

        return new OptionalNode($body, $token->getLine(), $this->getTag());
    }
1276900
protected function createNodeScheduled(PublishNode $command, Pbjx $pbjx): NodeScheduled
    {
        /** @var NodeScheduled $event */
        $event = $this->createEventFromCommand($command, 'scheduled');
        return $event;
    }
1110935
public function toXml(\SimpleXmlElement $root) {
    	$methodNode = $root->addChild("method");
    	$methodNode->addAttribute("name", $this->getName());
    	$modifier = "";
    	if ($this->isPublic()) {
    		$modifier = "public";
    	} elseif ($this->isProtected()) {
    		$modifier = "protected";
    	} elseif ($this->isPrivate()) {
    		$modifier = "private";
    	}
    	$methodNode->addAttribute("modifier", $modifier);
    	$methodNode->addAttribute("static", $this->isStatic()?"true":"false");
    	$methodNode->addAttribute("abstract", $this->isAbstract()?"true":"false");
    	$methodNode->addAttribute("constructor", $this->isConstructor()?"true":"false");
    	$methodNode->addAttribute("final", $this->isFinal()?"true":"false");
    	$commentNode = $methodNode->addChild("comment");
    	
    	$node= dom_import_simplexml($commentNode);
   		$no = $node->ownerDocument;
   		$node->appendChild($no->createCDATASection($this->getDocComment())); 
    	
    	
    	foreach ($this->getParameters() as $parameter) {
    		$parameter->toXml($methodNode);
    	}
    }
256586
public function build(): SetInspectedNodeRequest
	{
		$instance = new SetInspectedNodeRequest();
		if ($this->nodeId === null) {
			throw new BuilderException('Property [nodeId] is required.');
		}
		$instance->nodeId = $this->nodeId;
		return $instance;
	}
624319
protected function handle(GetNodeRequest $request, Pbjx $pbjx): GetNodeResponse
    {
        $context = $this->createNcrContext($request);

        if ($request->has('node_ref')) {
            $node = $this->ncr->getNode(
                $request->get('node_ref'),
                $request->get('consistent_read'),
                $context
            );
        } elseif ($request->has('slug')) {
            $qname = SchemaQName::fromString($request->get('qname'));
            $query = IndexQueryBuilder::create($qname, 'slug', $request->get('slug'))
                ->setCount(1)
                ->build();
            $result = $this->ncr->findNodeRefs($query, $context);
            if (!$result->count()) {
                throw new NodeNotFound("Unable to locate {$qname->getMessage()}.");
            }

            $node = $this->ncr->getNode(
                $result->getNodeRefs()[0],
                $request->get('consistent_read'),
                $context
            );
        } else {
            throw new NodeNotFound('No method to locate node.');
        }

        $this->assertIsNodeSupported($node);
        return $this->createGetNodeResponse($request, $pbjx)->set('node', $node);
    }
384973
private function newExpr() {
    $node = new NewNode();
    $this->mustMatch(T_NEW, $node);
    $node->addChild($this->classNameReference(), 'className');
    if ($this->currentType === '(') {
      $this->functionCallParameterList($node);
    }
    return $node;
  }
12037
protected function createNodeMarkedAsPending(MarkNodeAsPending $command, Pbjx $pbjx): NodeMarkedAsPending
    {
        /** @var NodeMarkedAsPending $event */
        $event = $this->createEventFromCommand($command, 'marked-as-pending');
        return $event;
    }
793476
public static function fromString(string $token): self
    {
        $instance = new self();
        $instance->token = $token;

        $parsed = explode('.', $token);
        if (count($parsed) !== 3) {
            throw new InvalidArgumentException('PbjxToken string is invalid.');
        }

        $instance->header = json_decode(self::urlsafeB64Decode($parsed[0]), true);
        $instance->payload = json_decode(self::urlsafeB64Decode($parsed[1]), true);
        $instance->signature = self::urlsafeB64Decode($parsed[2]);
        $instance->checkClaims();

        $instance->payload['exp'] = (int)$instance->payload['exp'];
        $instance->payload['iat'] = (int)$instance->payload['iat'];

        return $instance;
    }
719732
public static function selectNodes(\DOMNode $pNode, $xPath, $arNamespace = null) // <- Retorna N&#65533;!
    {
        if (preg_match('~^/[^/]~', $xPath)) {
            $xPath = substr($xPath, 1);
        }

        $owner = XmlUtil::getOwnerDocument($pNode);
        $xpath = new DOMXPath($owner);
        XmlUtil::registerNamespaceForFilter($xpath, $arNamespace);
        $rNodeList = $xpath->query($xPath, $pNode);

        return $rNodeList;
    }
503130
public function xPathQuery($pQuery, $pNode = NULL)
    {
        $queryResult = $this->_getXPath()->query($pQuery, $pNode);
        if ($queryResult === false) {
            throw new Exception("Invalid XPath request");
        }

        return $queryResult;
    }
952507
protected function createUserRolesGranted(GrantRolesToUser $command, Pbjx $pbjx): UserRolesGranted
    {
        /** @var UserRolesGranted $event */
        $event = UserRolesGrantedV1Mixin::findOne()->createMessage();
        return $event;
    }
117716
public function build(): SetEventListenerBreakpointRequest
	{
		$instance = new SetEventListenerBreakpointRequest();
		if ($this->eventName === null) {
			throw new BuilderException('Property [eventName] is required.');
		}
		$instance->eventName = $this->eventName;
		$instance->targetName = $this->targetName;
		return $instance;
	}