Fixed phpstan issues in GenericWebProvider

This commit is contained in:
Jan Böhmer 2026-02-07 17:07:53 +01:00
parent 851055bdb4
commit 061af28c48
2 changed files with 6 additions and 6 deletions

View file

@ -67,3 +67,6 @@ parameters:
-
message: '#Should not use function "shell_exec"#'
path: src/Services/System/UpdateExecutor.php
- message: '#Access to an undefined property Brick\\Schema\\Interfaces\\#'
path: src/Services/InfoProviderSystem/Providers/GenericWebProvider.php

View file

@ -213,14 +213,14 @@ class GenericWebProvider implements InfoProviderInterface
//Try to extract weight
$mass = null;
if (($weight = $product?->weight->getFirstValue()) instanceof QuantitativeValue) {
if (($weight = $product->weight?->getFirstValue()) instanceof QuantitativeValue) {
$mass = $weight->value->toString();
}
return new PartDetailDTO(
provider_key: $this->getProviderKey(),
provider_id: $url,
name: $product->name?->toString() ?? $product->alternateName?->toString() ?? $product?->mpn->toString() ?? 'Unknown Name',
name: $product->name?->toString() ?? $product->alternateName?->toString() ?? $product->mpn?->toString() ?? 'Unknown Name',
description: $this->getMetaContent($dom, 'og:description') ?? $this->getMetaContent($dom, 'description') ?? '',
category: $this->breadcrumbToCategory($categoryBreadcrumb) ?? $product->category?->toString(),
manufacturer: self::propertyOrString($product->manufacturer) ?? self::propertyOrString($product->brand),
@ -247,10 +247,7 @@ class GenericWebProvider implements InfoProviderInterface
return $value;
}
if ($value instanceof Thing) {
return $value->$property?->toString();
}
return null;
return $value->$property?->toString();
}