web/lib/Contributor.php
Mike Colagrosso 2098b265a8 Rename the constructor Ebook::__construct() to static Ebook::FromFilesystem()
Also added `GetFoo()` methods for all the derived properties like `GetUrl()`, `GetHasDownloads()`, etc. Removed that logic from the constructor so that it's reusable in `Ebook::FromFilesystem()` and `Ebook::GetByIdentifier()`
2024-11-04 13:16:56 -06:00

22 lines
792 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?
class Contributor{
public string $Name;
public string $UrlName;
public ?string $SortName = null;
public ?string $WikipediaUrl = null;
public ?string $MarcRole = null;
public ?string $FullName = null;
public ?string $NacoafUrl = null;
public static function FromProperties(string $name, string $sortName = null, string $fullName = null, string $wikipediaUrl = null, string $marcRole = null, string $nacoafUrl = null): Contributor{
$instance = new Contributor();
$instance->Name = str_replace('\'', '', $name);
$instance->UrlName = Formatter::MakeUrlSafe($name);
$instance->SortName = $sortName;
$instance->FullName = $fullName;
$instance->WikipediaUrl = $wikipediaUrl;
$instance->MarcRole = $marcRole;
$instance->NacoafUrl = $nacoafUrl;
return $instance;
}
}