
| Current Path : /var/www/html/rocksensor1/vendor/chi-teck/drupal-code-generator/src/Validator/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/www/html/rocksensor1/vendor/chi-teck/drupal-code-generator/src/Validator/ServiceExists.php |
<?php
declare(strict_types=1);
namespace DrupalCodeGenerator\Validator;
use DrupalCodeGenerator\Helper\Drupal\ServiceInfo;
/**
* Validates that service with a given name exists.
*/
final class ServiceExists {
/**
* Constructs the object.
*/
public function __construct(
private readonly ServiceInfo $serviceInfo,
) {}
/**
* @throws \UnexpectedValueException
*/
public function __invoke(string $value): string {
if (!$this->serviceInfo->getServiceDefinition($value)) {
throw new \UnexpectedValueException('Service does not exists.');
}
return $value;
}
}