*/
final readonly class Spider
{
+ public string $identifier;
+
public function __construct(
- public string $identifier,
+ string $identifier,
public string $name,
public ?string $url = null,
) {
+ $this->identifier = \mb_strtolower($identifier);
}
}
*/
public function register(Spider $spider): void
{
- $identifier = \mb_strtolower($spider->identifier);
- if (\array_key_exists($identifier, $this->spiders)) {
- throw new \InvalidArgumentException('Spider with identifier ' . $identifier . ' already exists');
+ if (\array_key_exists($spider->identifier, $this->spiders)) {
+ throw new \InvalidArgumentException('Spider with identifier ' . $spider->identifier . ' already exists');
}
- $this->spiders[$identifier] = $spider;
+ $this->spiders[$spider->identifier] = $spider;
}
/**