WIP: Symfony 6 project remake #2

Draft
skobkin wants to merge 103 commits from symfony6_remake into master
16 changed files with 113 additions and 109 deletions
Showing only changes of commit 64b042bf77 - Show all commits

View file

@ -1,8 +0,0 @@
<?php
namespace src\PointToolsBundle\Exception\Api;
class ApiException extends \Exception
{
}

View file

@ -1,10 +0,0 @@
<?php
namespace src\PointToolsBundle\Exception\Api;
use src\PointToolsBundle\Exception\Api\ApiException;
class ForbiddenException extends ApiException
{
}

View file

@ -1,10 +0,0 @@
<?php
namespace src\PointToolsBundle\Exception\Api;
use src\PointToolsBundle\Exception\Api\ApiException;
class InvalidResponseException extends ApiException
{
}

View file

@ -1,10 +0,0 @@
<?php
namespace src\PointToolsBundle\Exception\Api;
use src\PointToolsBundle\Exception\Api\ApiException;
class NetworkException extends ApiException
{
}

View file

@ -1,10 +0,0 @@
<?php
namespace src\PointToolsBundle\Exception\Api;
use src\PointToolsBundle\Exception\Api\ApiException;
class NotFoundException extends ApiException
{
}

View file

@ -1,10 +0,0 @@
<?php
namespace src\PointToolsBundle\Exception\Api;
use src\PointToolsBundle\Exception\Api\ApiException;
class ServerProblemException extends ApiException
{
}

View file

@ -1,10 +0,0 @@
<?php
namespace src\PointToolsBundle\Exception\Api;
use src\PointToolsBundle\Exception\Api\ApiException;
class UnauthorizedException extends ApiException
{
}

View file

@ -1,41 +0,0 @@
<?php
namespace src\PointToolsBundle\Exception\Api;
use src\PointToolsBundle\Exception\Api\NotFoundException;
class UserNotFoundException extends NotFoundException
{
/**
* @var int
*/
protected $userId;
/**
* @var string
*/
protected $login;
/**
* {@inheritdoc}
* @param int $userId
*/
public function __construct($message = 'User not found', $code = 0, \Exception $previous = null, $userId = null, $login = null)
{
parent::__construct($message, $code, $previous);
$this->userId = $userId;
$this->login = $login;
}
public function getUserId(): int
{
return $this->userId;
}
public function getLogin(): string
{
return $this->login;
}
}

View file

@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace App\Exception\Api;
class ApiException extends \Exception
{
}

View file

@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
namespace App\Exception\Api;
class ForbiddenException extends ApiException
{
public function __construct(
string $message = 'Forbidden',
int $code = 403,
?\Throwable $previous = null
) {
parent::__construct($message, $code, $previous);
}
}

View file

@ -0,0 +1,8 @@
<?php
declare(strict_types=1);
namespace App\Exception\Api;
class InvalidResponseException extends ApiException
{
}

View file

@ -0,0 +1,9 @@
<?php
declare(strict_types=1);
namespace App\Exception\Api;
class NetworkException extends ApiException
{
}

View file

@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
namespace App\Exception\Api;
class NotFoundException extends ApiException
{
public function __construct(
string $message = 'Resource not found',
int $code = 404,
?\Throwable $previous = null
) {
parent::__construct($message, $code, $previous);
}
}

View file

@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
namespace App\Exception\Api;
class ServerProblemException extends ApiException
{
public function __construct(
string $message = 'Server error',
int $code = 500,
?\Throwable $previous = null
) {
parent::__construct($message, $code, $previous);
}
}

View file

@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
namespace App\Exception\Api;
class UnauthorizedException extends ApiException
{
public function __construct(
string $message = 'Unauthorized',
int $code = 401,
?\Throwable $previous = null
) {
parent::__construct($message, $code, $previous);
}
}

View file

@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
namespace App\Exception\Api;
class UserNotFoundException extends NotFoundException
{
public function __construct(
$message = 'User not found',
$code = 0,
\Exception $previous = null,
private readonly ?int $userId = null,
private readonly ?string $login = null,
) {
parent::__construct($message, $code, $previous);
}
public function getUserId(): ?int
{
return $this->userId;
}
public function getLogin(): ?string
{
return $this->login;
}
}