priority !== null && ($this->priority < 0 || $this->priority > 10)) { throw new \LogicException('Priority must be in range [0; 10]', 1679601774); } if ($this->identifier === '') { throw new \LogicException('Identifer cannot be empty', 1679601795); } } public function hash(): string { return sha1(json_encode($this->getHashProperties())); } public function hmac(): string { $hashService = GeneralUtility::makeInstance(HashService::class); return $hashService->hmac(json_encode($this->getHashProperties()), self::class); } public function jsonSerialize(): array { $properties = [ 'collection' => $this->collection, 'identifier' => $this->identifier, 'priority' => $this->priority, 'label' => $this->label, ]; $hashService = GeneralUtility::makeInstance(HashService::class); $hashContent = json_encode($this->getHashProperties()); $properties['hash'] = sha1($hashContent); $properties['hmac'] = $hashService->hmac($hashContent, self::class); return $properties; } private function getHashProperties(): array { return [ 'collection' => $this->collection, 'identifier' => $this->identifier, ]; } }