Initial project structure with Slim skeleton

This commit is contained in:
Gregory Ballantine
2022-07-09 12:25:26 -04:00
commit 14735bd9a5
43 changed files with 4878 additions and 0 deletions

56
src/Domain/User/User.php Normal file
View File

@ -0,0 +1,56 @@
<?php
declare(strict_types=1);
namespace App\Domain\User;
use JsonSerializable;
class User implements JsonSerializable
{
private ?int $id;
private string $username;
private string $firstName;
private string $lastName;
public function __construct(?int $id, string $username, string $firstName, string $lastName)
{
$this->id = $id;
$this->username = strtolower($username);
$this->firstName = ucfirst($firstName);
$this->lastName = ucfirst($lastName);
}
public function getId(): ?int
{
return $this->id;
}
public function getUsername(): string
{
return $this->username;
}
public function getFirstName(): string
{
return $this->firstName;
}
public function getLastName(): string
{
return $this->lastName;
}
#[\ReturnTypeWillChange]
public function jsonSerialize(): array
{
return [
'id' => $this->id,
'username' => $this->username,
'firstName' => $this->firstName,
'lastName' => $this->lastName,
];
}
}

View File

@ -0,0 +1,11 @@
<?php
declare(strict_types=1);
namespace App\Domain\User;
use App\Domain\DomainException\DomainRecordNotFoundException;
class UserNotFoundException extends DomainRecordNotFoundException
{
public $message = 'The user you requested does not exist.';
}

View File

@ -0,0 +1,19 @@
<?php
declare(strict_types=1);
namespace App\Domain\User;
interface UserRepository
{
/**
* @return User[]
*/
public function findAll(): array;
/**
* @param int $id
* @return User
* @throws UserNotFoundException
*/
public function findUserOfId(int $id): User;
}