mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-12-07 19:49:30 +00:00
Made classes readonly where possible
This commit is contained in:
parent
27a18bdc1e
commit
eda6deff47
4 changed files with 26 additions and 26 deletions
|
|
@ -28,12 +28,12 @@ namespace App\Services\InfoProviderSystem\DTOs;
|
||||||
* This could be a datasheet, a 3D model, a picture or similar.
|
* This could be a datasheet, a 3D model, a picture or similar.
|
||||||
* @see \App\Tests\Services\InfoProviderSystem\DTOs\FileDTOTest
|
* @see \App\Tests\Services\InfoProviderSystem\DTOs\FileDTOTest
|
||||||
*/
|
*/
|
||||||
class FileDTO
|
readonly class FileDTO
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string The URL where to get this file
|
* @var string The URL where to get this file
|
||||||
*/
|
*/
|
||||||
public readonly string $url;
|
public string $url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $url The URL where to get this file
|
* @param string $url The URL where to get this file
|
||||||
|
|
@ -41,7 +41,7 @@ class FileDTO
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
string $url,
|
string $url,
|
||||||
public readonly ?string $name = null,
|
public ?string $name = null,
|
||||||
) {
|
) {
|
||||||
//Find all occurrences of non URL safe characters and replace them with their URL encoded version.
|
//Find all occurrences of non URL safe characters and replace them with their URL encoded version.
|
||||||
//We only want to replace characters which can not have a valid meaning in a URL (what would break the URL).
|
//We only want to replace characters which can not have a valid meaning in a URL (what would break the URL).
|
||||||
|
|
|
||||||
|
|
@ -28,17 +28,17 @@ namespace App\Services\InfoProviderSystem\DTOs;
|
||||||
* This could be a voltage, a current, a temperature or similar.
|
* This could be a voltage, a current, a temperature or similar.
|
||||||
* @see \App\Tests\Services\InfoProviderSystem\DTOs\ParameterDTOTest
|
* @see \App\Tests\Services\InfoProviderSystem\DTOs\ParameterDTOTest
|
||||||
*/
|
*/
|
||||||
class ParameterDTO
|
readonly class ParameterDTO
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
public readonly string $name,
|
public string $name,
|
||||||
public readonly ?string $value_text = null,
|
public ?string $value_text = null,
|
||||||
public readonly ?float $value_typ = null,
|
public ?float $value_typ = null,
|
||||||
public readonly ?float $value_min = null,
|
public ?float $value_min = null,
|
||||||
public readonly ?float $value_max = null,
|
public ?float $value_max = null,
|
||||||
public readonly ?string $unit = null,
|
public ?string $unit = null,
|
||||||
public readonly ?string $symbol = null,
|
public ?string $symbol = null,
|
||||||
public readonly ?string $group = null,
|
public ?string $group = null,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,21 +28,21 @@ use Brick\Math\BigDecimal;
|
||||||
/**
|
/**
|
||||||
* This DTO represents a price for a single unit in a certain discount range
|
* This DTO represents a price for a single unit in a certain discount range
|
||||||
*/
|
*/
|
||||||
class PriceDTO
|
readonly class PriceDTO
|
||||||
{
|
{
|
||||||
private readonly BigDecimal $price_as_big_decimal;
|
private BigDecimal $price_as_big_decimal;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
/** @var float The minimum amount that needs to get ordered for this price to be valid */
|
/** @var float The minimum amount that needs to get ordered for this price to be valid */
|
||||||
public readonly float $minimum_discount_amount,
|
public float $minimum_discount_amount,
|
||||||
/** @var string The price as string (with .) */
|
/** @var string The price as string (with .) */
|
||||||
public readonly string $price,
|
public string $price,
|
||||||
/** @var string The currency of the used ISO code of this price detail */
|
/** @var string The currency of the used ISO code of this price detail */
|
||||||
public readonly ?string $currency_iso_code,
|
public ?string $currency_iso_code,
|
||||||
/** @var bool If the price includes tax */
|
/** @var bool If the price includes tax */
|
||||||
public readonly ?bool $includes_tax = true,
|
public ?bool $includes_tax = true,
|
||||||
/** @var float the price related quantity */
|
/** @var float the price related quantity */
|
||||||
public readonly ?float $price_related_quantity = 1.0,
|
public ?float $price_related_quantity = 1.0,
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
$this->price_as_big_decimal = BigDecimal::of($this->price);
|
$this->price_as_big_decimal = BigDecimal::of($this->price);
|
||||||
|
|
|
||||||
|
|
@ -27,15 +27,15 @@ namespace App\Services\InfoProviderSystem\DTOs;
|
||||||
* This DTO represents a purchase information for a part (supplier name, order number and prices).
|
* This DTO represents a purchase information for a part (supplier name, order number and prices).
|
||||||
* @see \App\Tests\Services\InfoProviderSystem\DTOs\PurchaseInfoDTOTest
|
* @see \App\Tests\Services\InfoProviderSystem\DTOs\PurchaseInfoDTOTest
|
||||||
*/
|
*/
|
||||||
class PurchaseInfoDTO
|
readonly class PurchaseInfoDTO
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
public readonly string $distributor_name,
|
public string $distributor_name,
|
||||||
public readonly string $order_number,
|
public string $order_number,
|
||||||
/** @var PriceDTO[] */
|
/** @var PriceDTO[] */
|
||||||
public readonly array $prices,
|
public array $prices,
|
||||||
/** @var string|null An url to the product page of the vendor */
|
/** @var string|null An url to the product page of the vendor */
|
||||||
public readonly ?string $product_url = null,
|
public ?string $product_url = null,
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//Ensure that the prices are PriceDTO instances
|
//Ensure that the prices are PriceDTO instances
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue