chore: Update copyright year from 2025 to 2026 across core files
- Updated copyright headers in 3,055 core application files - Changed 'Copyright (C) 2014-2025' to 'Copyright (C) 2014-2026' - Added 123 new files from EspoCRM core updates - Removed 4 deprecated files - Total changes: 61,637 insertions, 54,283 deletions This is a routine maintenance update for the new year 2026.
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -31,7 +31,6 @@ namespace Espo\Core\Field;
|
||||
|
||||
use Espo\Core\Currency\CalculatorUtil;
|
||||
|
||||
use RuntimeException;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
@@ -46,7 +45,7 @@ class Currency
|
||||
/**
|
||||
* @param numeric-string|float|int $amount An amount.
|
||||
* @param string $code A currency code.
|
||||
* @throws RuntimeException
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function __construct($amount, string $code)
|
||||
{
|
||||
@@ -55,7 +54,7 @@ class Currency
|
||||
}
|
||||
|
||||
if (strlen($code) !== 3) {
|
||||
throw new RuntimeException("Bad currency code.");
|
||||
throw new InvalidArgumentException("Bad currency code.");
|
||||
}
|
||||
|
||||
if (is_float($amount) || is_int($amount)) {
|
||||
@@ -95,12 +94,12 @@ class Currency
|
||||
/**
|
||||
* Add a currency value.
|
||||
*
|
||||
* @throws RuntimeException If currency codes are different.
|
||||
* @throws InvalidArgumentException If currency codes are different.
|
||||
*/
|
||||
public function add(self $value): self
|
||||
{
|
||||
if ($this->getCode() !== $value->getCode()) {
|
||||
throw new RuntimeException("Can't add a currency value with a different code.");
|
||||
throw new InvalidArgumentException("Can't add a currency value with a different code.");
|
||||
}
|
||||
|
||||
$amount = CalculatorUtil::add(
|
||||
@@ -114,12 +113,12 @@ class Currency
|
||||
/**
|
||||
* Subtract a currency value.
|
||||
*
|
||||
* @throws RuntimeException If currency codes are different.
|
||||
* @throws InvalidArgumentException If currency codes are different.
|
||||
*/
|
||||
public function subtract(self $value): self
|
||||
{
|
||||
if ($this->getCode() !== $value->getCode()) {
|
||||
throw new RuntimeException("Can't subtract a currency value with a different code.");
|
||||
throw new InvalidArgumentException("Can't subtract a currency value with a different code.");
|
||||
}
|
||||
|
||||
$amount = CalculatorUtil::subtract(
|
||||
@@ -132,8 +131,10 @@ class Currency
|
||||
|
||||
/**
|
||||
* Multiply by a multiplier.
|
||||
*
|
||||
* @param float|int|numeric-string $multiplier
|
||||
*/
|
||||
public function multiply(float|int $multiplier): self
|
||||
public function multiply(float|int|string $multiplier): self
|
||||
{
|
||||
$amount = CalculatorUtil::multiply(
|
||||
$this->getAmountAsString(),
|
||||
@@ -145,8 +146,10 @@ class Currency
|
||||
|
||||
/**
|
||||
* Divide by a divider.
|
||||
*
|
||||
* @param float|int|numeric-string $divider
|
||||
*/
|
||||
public function divide(float|int $divider): self
|
||||
public function divide(float|int|string $divider): self
|
||||
{
|
||||
$amount = CalculatorUtil::divide(
|
||||
$this->getAmountAsString(),
|
||||
@@ -172,12 +175,12 @@ class Currency
|
||||
* - `0` if equal to the value;
|
||||
* - `-1` if less than the value.
|
||||
*
|
||||
* @throws RuntimeException If currency codes are different.
|
||||
* @throws InvalidArgumentException If currency codes are different.
|
||||
*/
|
||||
public function compare(self $value): int
|
||||
{
|
||||
if ($this->getCode() !== $value->getCode()) {
|
||||
throw new RuntimeException("Can't compare currencies with different codes.");
|
||||
throw new InvalidArgumentException("Can't compare currencies with different codes.");
|
||||
}
|
||||
|
||||
return CalculatorUtil::compare(
|
||||
@@ -199,7 +202,7 @@ class Currency
|
||||
*
|
||||
* @param numeric-string|float|int $amount An amount.
|
||||
* @param string $code A currency code.
|
||||
* @throws RuntimeException
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public static function create($amount, string $code): self
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -35,6 +35,7 @@ use DateTimeImmutable;
|
||||
use DateTimeInterface;
|
||||
use DateInterval;
|
||||
use DateTimeZone;
|
||||
use InvalidArgumentException;
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
@@ -45,12 +46,15 @@ class Date implements DateTimeable
|
||||
private string $value;
|
||||
private DateTimeImmutable $dateTime;
|
||||
|
||||
private const SYSTEM_FORMAT = 'Y-m-d';
|
||||
private const string SYSTEM_FORMAT = 'Y-m-d';
|
||||
|
||||
/**
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function __construct(string $value)
|
||||
{
|
||||
if (!$value) {
|
||||
throw new RuntimeException("Empty value.");
|
||||
throw new InvalidArgumentException("Empty value.");
|
||||
}
|
||||
|
||||
$this->value = $value;
|
||||
@@ -62,13 +66,13 @@ class Date implements DateTimeable
|
||||
);
|
||||
|
||||
if ($parsedValue === false) {
|
||||
throw new RuntimeException("Bad value.");
|
||||
throw new InvalidArgumentException("Bad value.");
|
||||
}
|
||||
|
||||
$this->dateTime = $parsedValue;
|
||||
|
||||
if ($this->value !== $this->dateTime->format(self::SYSTEM_FORMAT)) {
|
||||
throw new RuntimeException("Bad value.");
|
||||
throw new InvalidArgumentException("Bad value.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,6 +263,8 @@ class Date implements DateTimeable
|
||||
|
||||
/**
|
||||
* Create from a string with a date in `Y-m-d` format.
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public static function fromString(string $value): self
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -36,6 +36,7 @@ use DateTimeInterface;
|
||||
use DateInterval;
|
||||
use DateTimeZone;
|
||||
use RuntimeException;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* A date-time value object. Immutable.
|
||||
@@ -45,12 +46,15 @@ class DateTime implements DateTimeable
|
||||
private string $value;
|
||||
private DateTimeImmutable $dateTime;
|
||||
|
||||
private const SYSTEM_FORMAT = 'Y-m-d H:i:s';
|
||||
private const string SYSTEM_FORMAT = 'Y-m-d H:i:s';
|
||||
|
||||
/**
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function __construct(string $value)
|
||||
{
|
||||
if (!$value) {
|
||||
throw new RuntimeException("Empty value.");
|
||||
throw new InvalidArgumentException("Empty value.");
|
||||
}
|
||||
|
||||
$normValue = strlen($value) === 16 ? $value . ':00' : $value;
|
||||
@@ -64,13 +68,13 @@ class DateTime implements DateTimeable
|
||||
);
|
||||
|
||||
if ($parsedValue === false) {
|
||||
throw new RuntimeException("Bad value.");
|
||||
throw new InvalidArgumentException("Bad value.");
|
||||
}
|
||||
|
||||
$this->dateTime = $parsedValue;
|
||||
|
||||
if ($this->value !== $this->dateTime->format(self::SYSTEM_FORMAT)) {
|
||||
throw new RuntimeException("Bad value.");
|
||||
throw new InvalidArgumentException("Bad value.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,6 +347,8 @@ class DateTime implements DateTimeable
|
||||
|
||||
/**
|
||||
* Create from a string with a date-time in `Y-m-d H:i:s` format.
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public static function fromString(string $value): self
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -35,7 +35,7 @@ use DateTimeImmutable;
|
||||
use DateTimeInterface;
|
||||
use DateInterval;
|
||||
use DateTimeZone;
|
||||
use RuntimeException;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* A date-time or date. Immutable.
|
||||
@@ -45,9 +45,12 @@ class DateTimeOptional implements DateTimeable
|
||||
private ?DateTime $dateTimeValue = null;
|
||||
private ?Date $dateValue = null;
|
||||
|
||||
private const SYSTEM_FORMAT = 'Y-m-d H:i:s';
|
||||
private const SYSTEM_FORMAT_DATE = 'Y-m-d';
|
||||
private const string SYSTEM_FORMAT = 'Y-m-d H:i:s';
|
||||
private const string SYSTEM_FORMAT_DATE = 'Y-m-d';
|
||||
|
||||
/**
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function __construct(string $value)
|
||||
{
|
||||
if (self::isStringDateTime($value)) {
|
||||
@@ -59,6 +62,8 @@ class DateTimeOptional implements DateTimeable
|
||||
|
||||
/**
|
||||
* Create from a string with a date-time in `Y-m-d H:i:s` format or date in `Y-m-d`.
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public static function fromString(string $value): self
|
||||
{
|
||||
@@ -67,12 +72,14 @@ class DateTimeOptional implements DateTimeable
|
||||
|
||||
/**
|
||||
* Create from a string with a date-time in `Y-m-d H:i:s` format.
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public static function fromDateTimeString(string $value): self
|
||||
{
|
||||
if (!self::isStringDateTime($value)) {
|
||||
throw new RuntimeException("Bad value.");
|
||||
throw new InvalidArgumentException("Bad value.");
|
||||
}
|
||||
|
||||
return self::fromString($value);
|
||||
@@ -434,12 +441,14 @@ class DateTimeOptional implements DateTimeable
|
||||
|
||||
/**
|
||||
* Create from a string with a date in `Y-m-d` format.
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public static function fromDateString(string $value): self
|
||||
{
|
||||
if (self::isStringDateTime($value)) {
|
||||
throw new RuntimeException("Bad value.");
|
||||
throw new InvalidArgumentException("Bad value.");
|
||||
}
|
||||
|
||||
return self::fromString($value);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -29,9 +29,9 @@
|
||||
|
||||
namespace Espo\Core\Field;
|
||||
|
||||
use RuntimeException;
|
||||
use InvalidArgumentException;
|
||||
|
||||
use FILTER_VALIDATE_EMAIL;
|
||||
use const FILTER_VALIDATE_EMAIL;
|
||||
|
||||
/**
|
||||
* An email address value. Immutable.
|
||||
@@ -42,14 +42,17 @@ class EmailAddress
|
||||
private bool $isOptedOut = false;
|
||||
private bool $isInvalid = false;
|
||||
|
||||
/**
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function __construct(string $address)
|
||||
{
|
||||
if ($address === '') {
|
||||
throw new RuntimeException("Empty email address.");
|
||||
throw new InvalidArgumentException("Empty email address.");
|
||||
}
|
||||
|
||||
if (!filter_var($address, FILTER_VALIDATE_EMAIL)) {
|
||||
throw new RuntimeException("Not valid email address '{$address}'.");
|
||||
throw new InvalidArgumentException("Not valid email address '$address'.");
|
||||
}
|
||||
|
||||
$this->address = $address;
|
||||
@@ -129,6 +132,8 @@ class EmailAddress
|
||||
|
||||
/**
|
||||
* Create from an address.
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public static function create(string $address): self
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
namespace Espo\Core\Field;
|
||||
|
||||
use RuntimeException;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* An email address group. Contains a list of email addresses. One email address is set as primary.
|
||||
@@ -43,7 +43,7 @@ class EmailAddressGroup
|
||||
|
||||
/**
|
||||
* @param EmailAddress[] $list
|
||||
* @throws RuntimeException
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function __construct(array $list = [])
|
||||
{
|
||||
@@ -80,11 +80,7 @@ class EmailAddressGroup
|
||||
{
|
||||
$primary = $this->getPrimary();
|
||||
|
||||
if (!$primary) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $primary->getAddress();
|
||||
return $primary?->getAddress();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -274,17 +270,20 @@ class EmailAddressGroup
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
private function validateList(): void
|
||||
{
|
||||
$addressList = [];
|
||||
|
||||
foreach ($this->list as $item) {
|
||||
if (!$item instanceof EmailAddress) {
|
||||
throw new RuntimeException("Bad item.");
|
||||
throw new InvalidArgumentException("Bad item.");
|
||||
}
|
||||
|
||||
if (in_array(strtolower($item->getAddress()), $addressList)) {
|
||||
throw new RuntimeException("Address list contains a duplicate.");
|
||||
throw new InvalidArgumentException("Address list contains a duplicate.");
|
||||
}
|
||||
|
||||
$addressList[] = strtolower($item->getAddress());
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
namespace Espo\Core\Field;
|
||||
|
||||
use RuntimeException;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* A link value object. Immutable.
|
||||
@@ -42,7 +42,7 @@ class Link
|
||||
public function __construct(string $id)
|
||||
{
|
||||
if (!$id) {
|
||||
throw new RuntimeException("Empty ID.");
|
||||
throw new InvalidArgumentException("Empty ID.");
|
||||
}
|
||||
|
||||
$this->id = $id;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
namespace Espo\Core\Field;
|
||||
|
||||
use RuntimeException;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* A link-multiple value object. Immutable.
|
||||
@@ -38,7 +38,7 @@ class LinkMultiple
|
||||
{
|
||||
/**
|
||||
* @param LinkMultipleItem[] $list
|
||||
* @throws RuntimeException
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function __construct(private array $list = [])
|
||||
{
|
||||
@@ -148,8 +148,7 @@ class LinkMultiple
|
||||
* Clone with an added item list.
|
||||
* .
|
||||
* @param LinkMultipleItem[] $list
|
||||
*
|
||||
* @throws RuntimeException
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function withAddedList(array $list): self
|
||||
{
|
||||
@@ -201,7 +200,7 @@ class LinkMultiple
|
||||
*
|
||||
* @param LinkMultipleItem[] $list
|
||||
*
|
||||
* @throws RuntimeException
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public static function create(array $list = []): self
|
||||
{
|
||||
@@ -214,11 +213,11 @@ class LinkMultiple
|
||||
|
||||
foreach ($this->list as $item) {
|
||||
if (!$item instanceof LinkMultipleItem) {
|
||||
throw new RuntimeException("Bad item.");
|
||||
throw new InvalidArgumentException("Bad item.");
|
||||
}
|
||||
|
||||
if (in_array($item->getId(), $idList)) {
|
||||
throw new RuntimeException("List contains duplicates.");
|
||||
throw new InvalidArgumentException("List contains duplicates.");
|
||||
}
|
||||
|
||||
$idList[] = strtolower($item->getId());
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
namespace Espo\Core\Field;
|
||||
|
||||
use RuntimeException;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* A link-multiple item. Immutable.
|
||||
@@ -42,12 +42,12 @@ class LinkMultipleItem
|
||||
private array $columnData = [];
|
||||
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function __construct(string $id)
|
||||
{
|
||||
if ($id === '') {
|
||||
throw new RuntimeException("Empty ID.");
|
||||
throw new InvalidArgumentException("Empty ID.");
|
||||
}
|
||||
|
||||
$this->id = $id;
|
||||
@@ -124,7 +124,7 @@ class LinkMultipleItem
|
||||
/**
|
||||
* Create.
|
||||
*
|
||||
* @throws RuntimeException
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public static function create(string $id, ?string $name = null): self
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -30,7 +30,7 @@
|
||||
namespace Espo\Core\Field;
|
||||
|
||||
use Espo\ORM\Entity;
|
||||
use RuntimeException;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* A link-parent value object. Immutable.
|
||||
@@ -44,11 +44,11 @@ class LinkParent
|
||||
public function __construct(string $entityType, string $id)
|
||||
{
|
||||
if (!$entityType) {
|
||||
throw new RuntimeException("Empty entity type.");
|
||||
throw new InvalidArgumentException("Empty entity type.");
|
||||
}
|
||||
|
||||
if (!$id) {
|
||||
throw new RuntimeException("Empty ID.");
|
||||
throw new InvalidArgumentException("Empty ID.");
|
||||
}
|
||||
|
||||
$this->entityType = $entityType;
|
||||
@@ -93,6 +93,8 @@ class LinkParent
|
||||
|
||||
/**
|
||||
* Create.
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public static function create(string $entityType, string $id): self
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
namespace Espo\Core\Field;
|
||||
|
||||
use RuntimeException;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* A phone number value. Immutable.
|
||||
@@ -44,7 +44,7 @@ class PhoneNumber
|
||||
public function __construct(string $number)
|
||||
{
|
||||
if ($number === '') {
|
||||
throw new RuntimeException("Empty phone number.");
|
||||
throw new InvalidArgumentException("Empty phone number.");
|
||||
}
|
||||
|
||||
$this->number = $number;
|
||||
@@ -144,6 +144,8 @@ class PhoneNumber
|
||||
|
||||
/**
|
||||
* Create with a number.
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public static function create(string $number): self
|
||||
{
|
||||
@@ -152,6 +154,8 @@ class PhoneNumber
|
||||
|
||||
/**
|
||||
* Create from a number and type.
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public static function createWithType(string $number, string $type): self
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
namespace Espo\Core\Field;
|
||||
|
||||
use RuntimeException;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* A phone number group. Contains a list of phone numbers. One phone number is set as primary.
|
||||
@@ -43,8 +43,7 @@ class PhoneNumberGroup
|
||||
|
||||
/**
|
||||
* @param PhoneNumber[] $list
|
||||
*
|
||||
* @throws RuntimeException
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function __construct(array $list = [])
|
||||
{
|
||||
@@ -81,11 +80,8 @@ class PhoneNumberGroup
|
||||
{
|
||||
$primary = $this->getPrimary();
|
||||
|
||||
if (!$primary) {
|
||||
return null;
|
||||
}
|
||||
return $primary?->getNumber();
|
||||
|
||||
return $primary->getNumber();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -169,7 +165,7 @@ class PhoneNumberGroup
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether an number is in the list.
|
||||
* Whether the number is in the list.
|
||||
*/
|
||||
public function hasNumber(string $number): bool
|
||||
{
|
||||
@@ -258,6 +254,7 @@ class PhoneNumberGroup
|
||||
* Create with an optional phone number list. A first item will be set as primary.
|
||||
*
|
||||
* @param PhoneNumber[] $list
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public static function create(array $list = []): self
|
||||
{
|
||||
@@ -281,11 +278,11 @@ class PhoneNumberGroup
|
||||
|
||||
foreach ($this->list as $item) {
|
||||
if (!$item instanceof PhoneNumber) {
|
||||
throw new RuntimeException("Bad item.");
|
||||
throw new InvalidArgumentException("Bad item.");
|
||||
}
|
||||
|
||||
if (in_array($item->getNumber(), $numberList)) {
|
||||
throw new RuntimeException("Number list contains a duplicate.");
|
||||
throw new InvalidArgumentException("Number list contains a duplicate.");
|
||||
}
|
||||
|
||||
$numberList[] = strtolower($item->getNumber());
|
||||
|
||||
Reference in New Issue
Block a user