count() ? $node->text() : null; } protected function getIntOrNullValue(Crawler $node): ?int { return 0 < $node->count() ? (int) $node->text() : null; } protected function getFloatOrNullValue(Crawler $node): ?float { return 0 < $node->count() ? $this->stringToFloat($node->text()) : null; } protected function getDateOrNullValue(Crawler $node): ?\DateTimeImmutable { return 0 < $node->count() ? $this->stringToDate($node->text()) : null; } protected function getDateTimeOrNullValue(Crawler $node): ?\DateTimeImmutable { return 0 < $node->count() ? $this->stringToDateTime($node->text()) : null; } protected function getBoolValue(Crawler $node): bool { return 0 < $node->count() && $this->stringToBool($node->text()); } /** @return list */ protected function getArrayValue(Crawler $node, string $separator = ','): array { if (0 === $node->count()) { return []; } return $this->stringToArray($node->text(), $separator); } protected function getAttrOrNullValue(Crawler $node, string $attribute): ?string { if (0 === $node->count()) { return null; } return $node->attr($attribute); } protected function getRequiredAttrValue(Crawler $node, string $attribute, string $context): string { $value = $this->getAttrOrNullValue($node, $attribute); if (null === $value || '' === trim($value)) { throw new \InvalidArgumentException(sprintf('Missing required attribute "%s" in %s.', $attribute, $context)); } return $value; } }