Add endpoint to get reviewer for an in-progress project

This commit is contained in:
Alex Cabal 2025-01-07 21:42:28 -06:00
parent 87620287f1
commit bc16b1fff8
5 changed files with 110 additions and 2 deletions

View file

@ -13,7 +13,8 @@ use function Safe\preg_match;
* @property ?Patron $Patron
* @property ?NewsletterSubscription $NewsletterSubscription
* @property ?Payment $LastPayment
* @property string $DisplayName A string that represent's the `User`'s name, or email, or ID.
* @property string $DisplayName The `User`'s name, or email, or ID.
* @property ?string $SortName The `User`'s name in an (attempted) sort order, or `null` if the `User` has no name.
*/
class User{
use Traits\Accessor;
@ -37,12 +38,41 @@ class User{
protected ?Patron $_Patron;
protected ?NewsletterSubscription $_NewsletterSubscription;
protected string $_DisplayName;
protected ?string $_SortName = null;
// *******
// GETTERS
// *******
protected function GetSortName(): string{
if(!isset($this->_SortName)){
if($this->Name !== null){
preg_match('/\s(?:de |de la |di |van |von )?[^\s]+$/iu', $this->Name, $lastNameMatches);
if(sizeof($lastNameMatches) == 0){
$this->SortName = $this->Name;
}
else{
$lastName = trim($lastNameMatches[0]);
preg_match('/^(.+)' . preg_quote($lastName, '/') . '$/u', $this->Name, $firstNameMatches);
if(sizeof($firstNameMatches) == 0){
$this->SortName = $this->Name;
}
else{
$this->_SortName = $lastName . ', ' . trim($firstNameMatches[1]);
}
}
}
else{
$this->_SortName = null;
}
}
return $this->_SortName;
}
protected function GetDisplayName(): string{
if(!isset($this->_DisplayName)){
if($this->Name !== null){