Skip to content

Instantly share code, notes, and snippets.

View dborsatto's full-sized avatar

Davide Borsatto dborsatto

View GitHub Profile
<?php
declare(strict_types=1);
namespace App\Shared\Id\Domain\Model;
use App\Shared\Id\Domain\Exception\UuidIsNotValidException;
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface as RamseyUuidInterface;
use Throwable;
@dborsatto
dborsatto / Task.md
Last active May 27, 2021 12:02
Test application

Description

A doctor needs basic a system to book appointments for his patients. The application must support managing the list of patients, and the creation of appointments.

Each appointment must be set within working hours (9AM to 6PM) and have a duration set in multiple of 30 minutes (30 minutes, 1 hour, 1 hour and 30 minutes, etc). Appointments cannot overlap.

For each patient a list of basic info is required (first name, last name, email address and optionally a phone number). The email address must be validated using an API service of the candidate's choosing.

Patients need to be notified via email whenever an appointment is created or deleted.

@dborsatto
dborsatto / AbstractAnimal.php
Last active April 13, 2021 15:30
Interview questions
<?php
abstract class AbstractAnimal
{
public function walk()
{
}
}
class Cat extends AbstractAnimal
<?php
interface CanBeShownToUserExceptionInterface extends Throwable
{
public function getMessageForUser(): string;
}
class PostException extends Exception implements CanBeShownToUserExceptionInterface
{
private $messageForUser;
<?php
interface CacheInterface
{
public function getValue(string $key): string;
}
class RedisCache implements CacheInterface
{
public function getValue(string $key): string
<?php
class VerificationService
{
/**
* @throw VerificationException
*/
public function getVerificationResult($value): VerificationResult
{
try {
<?php
interface UserExceptionInterface extends Throwable
{
}
class UserCannotPublishPostException extends Exception implements UserExceptionInterface
{
}
<?php
/**
* @throws UserNotFoundException
* @throws InsufficientPermissionsException
* @throws ConnectionFailedException
*/
function publish(Post $post): void
{
// This may throw a UserNotFoundException
<?php
/**
* @throws VerificationException
*/
function getVerificationResult($value): VerificationResult
{
// ...
}
<?php
try {
$result = $service->getVerificationResult($value);
} catch (VerificationException $exception) {
// ...
return;
}
if (!$result->isVerified()) {
foreach ($result->getErrors() as $error) {