mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-27 08:03:37 +00:00
PHP had no regression coverage. Adds a php-app fixture (Composer + Pest) with language, run and debug smoke cases, and a php entry in the Language smoke workflow: PHP 8.5 with Xdebug via setup-php, Intelephense pinned like the other servers. Other languages' selectors are unchanged. Co-authored-by: lleviathe <95321986+lleviathe@users.noreply.github.com>
41 lines
989 B
PHP
41 lines
989 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Shipping;
|
|
|
|
use NoDiscard;
|
|
use Uri\Rfc3986\Uri;
|
|
|
|
final readonly class Parcel
|
|
{
|
|
public function __construct(
|
|
public string $code,
|
|
public string $store,
|
|
public int $weightGrams,
|
|
public Dimensions $dimensions,
|
|
public int $valueCents,
|
|
public ParcelStatus $status = ParcelStatus::Expected,
|
|
) {}
|
|
|
|
public function billableGrams(Route $route): int
|
|
{
|
|
return max($this->weightGrams, $this->dimensions->volumetricGrams, $route->minimumGrams());
|
|
}
|
|
|
|
#[NoDiscard('a parcel is immutable, use the returned one')]
|
|
public function moveTo(ParcelStatus $next): self
|
|
{
|
|
if (!$this->status->canMoveTo($next)) {
|
|
throw InvalidStatusTransition::between($this, $next);
|
|
}
|
|
|
|
return clone ($this, ['status' => $next]);
|
|
}
|
|
|
|
public function trackingUrl(Uri $tracker): Uri
|
|
{
|
|
return $tracker->withPath("/parcels/$this->code");
|
|
}
|
|
}
|