chore: Refactor Client naming

Signed-off-by: Rubén D <nuxsmin@syspass.org>
This commit is contained in:
Rubén D
2024-01-16 09:25:01 +01:00
parent c87f3abe39
commit 24fcc0abf4
19 changed files with 157 additions and 157 deletions

View File

@@ -26,7 +26,7 @@ namespace SP\Domain\Client\Ports;
use SP\DataModel\ItemSearchData;
use SP\Domain\Account\Ports\AccountFilterBuilder;
use SP\Domain\Client\Models\Client;
use SP\Domain\Client\Models\Client as ClientModel;
use SP\Domain\Common\Ports\RepositoryInterface;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
@@ -37,32 +37,32 @@ use SP\Infrastructure\Database\QueryResult;
/**
* Class ClientRepository
*
* @template T of Client
* @template T of ClientModel
*/
interface ClientRepositoryInterface extends RepositoryInterface
interface ClientRepository extends RepositoryInterface
{
/**
* Creates an item
*
* @param Client $client
* @param ClientModel $client
*
* @return QueryResult
* @throws DuplicatedItemException
* @throws SPException
*/
public function create(Client $client): QueryResult;
public function create(ClientModel $client): QueryResult;
/**
* Updates an item
*
* @param Client $client
* @param ClientModel $client
*
* @return int
* @throws ConstraintException
* @throws QueryException
* @throws DuplicatedItemException
*/
public function update(Client $client): int;
public function update(ClientModel $client): int;
/**
* Returns the item for given id

View File

@@ -38,7 +38,7 @@ use SP\Infrastructure\Database\QueryResult;
/**
* Interface ClientServiceInterface
*/
interface ClientServiceInterface
interface ClientService
{
/**
* @throws ConstraintException
@@ -67,7 +67,7 @@ interface ClientServiceInterface
* @throws QueryException
* @throws NoSuchItemException
*/
public function delete(int $id): ClientServiceInterface;
public function delete(int $id): ClientService;
/**
* @param int[] $ids

View File

@@ -28,8 +28,8 @@ use SP\Core\Application;
use SP\DataModel\ItemSearchData;
use SP\Domain\Account\Ports\AccountFilterBuilder;
use SP\Domain\Client\Models\Client as ClientModel;
use SP\Domain\Client\Ports\ClientRepositoryInterface;
use SP\Domain\Client\Ports\ClientServiceInterface;
use SP\Domain\Client\Ports\ClientRepository;
use SP\Domain\Client\Ports\ClientService;
use SP\Domain\Common\Models\Simple;
use SP\Domain\Common\Services\Service;
use SP\Domain\Common\Services\ServiceException;
@@ -47,11 +47,11 @@ use function SP\__u;
*
* @template T of ClientModel
*/
final class Client extends Service implements ClientServiceInterface
final class Client extends Service implements ClientService
{
public function __construct(
Application $application,
private readonly ClientRepositoryInterface $clientRepository,
Application $application,
private readonly ClientRepository $clientRepository,
private readonly AccountFilterBuilder $accountFilterUser
) {
parent::__construct($application);
@@ -108,12 +108,12 @@ final class Client extends Service implements ClientServiceInterface
/**
* @param int $id
*
* @return ClientServiceInterface
* @return ClientService
* @throws ConstraintException
* @throws NoSuchItemException
* @throws QueryException
*/
public function delete(int $id): ClientServiceInterface
public function delete(int $id): ClientService
{
if ($this->clientRepository->delete($id)->getAffectedNumRows() === 0) {
throw new NoSuchItemException(__u('Client not found'), SPException::INFO);

View File

@@ -38,7 +38,7 @@ use SP\Domain\Account\Ports\AccountService;
use SP\Domain\Account\Ports\AccountToTagService;
use SP\Domain\Category\Models\Category;
use SP\Domain\Category\Ports\CategoryService;
use SP\Domain\Client\Ports\ClientServiceInterface;
use SP\Domain\Client\Ports\ClientService;
use SP\Domain\Common\Services\Service;
use SP\Domain\Common\Services\ServiceException;
use SP\Domain\Config\Ports\ConfigDataInterface;
@@ -62,9 +62,9 @@ defined('APP_ROOT') || die();
final class XmlExportService extends Service implements XmlExportServiceInterface
{
private ConfigDataInterface $configData;
private PhpExtensionChecker $extensionChecker;
private ClientServiceInterface $clientService;
private AccountService $accountService;
private PhpExtensionChecker $extensionChecker;
private ClientService $clientService;
private AccountService $accountService;
private AccountToTagService $accountToTagService;
private CategoryService $categoryService;
private TagServiceInterface $tagService;
@@ -76,13 +76,13 @@ final class XmlExportService extends Service implements XmlExportServiceInterfac
private ?string $exportFile = null;
public function __construct(
Application $application,
PhpExtensionChecker $extensionChecker,
ClientServiceInterface $clientService,
AccountService $accountService,
AccountToTagService $accountToTagService,
CategoryService $categoryService,
TagServiceInterface $tagService
Application $application,
PhpExtensionChecker $extensionChecker,
ClientService $clientService,
AccountService $accountService,
AccountToTagService $accountToTagService,
CategoryService $categoryService,
TagServiceInterface $tagService
) {
parent::__construct($application);

View File

@@ -27,7 +27,7 @@ namespace SP\Domain\Import\Services;
use SP\Domain\Account\Ports\AccountService;
use SP\Domain\Category\Ports\CategoryService;
use SP\Domain\Client\Ports\ClientServiceInterface;
use SP\Domain\Client\Ports\ClientService;
use SP\Domain\Tag\Ports\TagServiceInterface;
/**
@@ -36,15 +36,15 @@ use SP\Domain\Tag\Ports\TagServiceInterface;
final class ImportHelper
{
private AccountService $accountService;
private CategoryService $categoryService;
private ClientServiceInterface $clientService;
private TagServiceInterface $tagService;
private CategoryService $categoryService;
private ClientService $clientService;
private TagServiceInterface $tagService;
public function __construct(
AccountService $accountService,
CategoryService $categoryService,
ClientServiceInterface $clientService,
TagServiceInterface $tagService
AccountService $accountService,
CategoryService $categoryService,
ClientService $clientService,
TagServiceInterface $tagService
) {
$this->accountService = $accountService;
$this->categoryService = $categoryService;
@@ -62,7 +62,7 @@ final class ImportHelper
return $this->categoryService;
}
public function getClientService(): ClientServiceInterface
public function getClientService(): ClientService
{
return $this->clientService;
}

View File

@@ -32,7 +32,7 @@ use SP\Domain\Account\Ports\AccountService;
use SP\Domain\Category\Models\Category;
use SP\Domain\Category\Ports\CategoryService;
use SP\Domain\Client\Models\Client;
use SP\Domain\Client\Ports\ClientServiceInterface;
use SP\Domain\Client\Ports\ClientService;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\NoSuchPropertyException;
use SP\Domain\Core\Exceptions\QueryException;
@@ -55,9 +55,9 @@ trait ImportTrait
protected int $counter = 0;
protected ImportParams $importParams;
private AccountService $accountService;
private CategoryService $categoryService;
private ClientServiceInterface $clientService;
private TagServiceInterface $tagService;
private CategoryService $categoryService;
private ClientService $clientService;
private TagServiceInterface $tagService;
private array $items;
/**

View File

@@ -26,8 +26,8 @@ namespace SP\Infrastructure\Client\Repositories;
use SP\DataModel\ItemSearchData;
use SP\Domain\Account\Ports\AccountFilterBuilder;
use SP\Domain\Client\Models\Client;
use SP\Domain\Client\Ports\ClientRepositoryInterface;
use SP\Domain\Client\Models\Client as ClientModel;
use SP\Domain\Client\Ports\ClientRepository;
use SP\Domain\Core\Exceptions\ConstraintException;
use SP\Domain\Core\Exceptions\QueryException;
use SP\Domain\Core\Exceptions\SPException;
@@ -42,9 +42,9 @@ use function SP\__u;
/**
* Class ClientRepository
*
* @template T of Client
* @template T of ClientModel
*/
final class ClientRepository extends Repository implements ClientRepositoryInterface
final class Client extends Repository implements ClientRepository
{
use RepositoryItemTrait;
@@ -53,13 +53,13 @@ final class ClientRepository extends Repository implements ClientRepositoryInter
/**
* Creates an item
*
* @param Client $client
* @param ClientModel $client
*
* @return QueryResult
* @throws DuplicatedItemException
* @throws SPException
*/
public function create(Client $client): QueryResult
public function create(ClientModel $client): QueryResult
{
if ($this->checkDuplicatedOnAdd($client)) {
throw new DuplicatedItemException(__u('Duplicated client'));
@@ -79,12 +79,12 @@ final class ClientRepository extends Repository implements ClientRepositoryInter
/**
* Checks whether the item is duplicated on adding
*
* @param Client $client
* @param ClientModel $client
* @return bool
* @throws ConstraintException
* @throws QueryException
*/
private function checkDuplicatedOnAdd(Client $client): bool
private function checkDuplicatedOnAdd(ClientModel $client): bool
{
$query = $this->queryFactory
->newSelect()
@@ -105,14 +105,14 @@ final class ClientRepository extends Repository implements ClientRepositoryInter
/**
* Updates an item
*
* @param Client $client
* @param ClientModel $client
*
* @return int
* @throws ConstraintException
* @throws QueryException
* @throws DuplicatedItemException
*/
public function update(Client $client): int
public function update(ClientModel $client): int
{
if ($this->checkDuplicatedOnUpdate($client)) {
throw new DuplicatedItemException(__u('Duplicated client'));
@@ -139,13 +139,13 @@ final class ClientRepository extends Repository implements ClientRepositoryInter
/**
* Checks whether the item is duplicated on updating
*
* @param Client $client
* @param ClientModel $client
*
* @return bool
* @throws ConstraintException
* @throws QueryException
*/
private function checkDuplicatedOnUpdate(Client $client): bool
private function checkDuplicatedOnUpdate(ClientModel $client): bool
{
$query = $this->queryFactory
->newSelect()
@@ -176,12 +176,12 @@ final class ClientRepository extends Repository implements ClientRepositoryInter
$query = $this->queryFactory
->newSelect()
->from(self::TABLE)
->cols(Client::getCols())
->cols(ClientModel::getCols())
->where('id = :id')
->bindValues(['id' => $clientId])
->limit(1);
$queryData = QueryData::buildWithMapper($query, Client::class);
$queryData = QueryData::buildWithMapper($query, ClientModel::class);
return $this->db->doSelect($queryData);
}
@@ -198,12 +198,12 @@ final class ClientRepository extends Repository implements ClientRepositoryInter
$query = $this->queryFactory
->newSelect()
->from(self::TABLE)
->cols(Client::getCols())
->cols(ClientModel::getCols())
->where('(name = :name OR hash = :hash)')
->bindValues(['name' => $name, 'hash' => $this->makeItemHash($name)])
->limit(1);
$queryData = QueryData::buildWithMapper($query, Client::class);
$queryData = QueryData::buildWithMapper($query, ClientModel::class);
return $this->db->doSelect($queryData);
}
@@ -218,9 +218,9 @@ final class ClientRepository extends Repository implements ClientRepositoryInter
$query = $this->queryFactory
->newSelect()
->from(self::TABLE)
->cols(Client::getCols());
->cols(ClientModel::getCols());
return $this->db->doSelect(QueryData::buildWithMapper($query, Client::class));
return $this->db->doSelect(QueryData::buildWithMapper($query, ClientModel::class));
}
/**
@@ -282,7 +282,7 @@ final class ClientRepository extends Repository implements ClientRepositoryInter
$query = $this->queryFactory
->newSelect()
->from(self::TABLE)
->cols(Client::getCols(['hash']))
->cols(ClientModel::getCols(['hash']))
->orderBy(['name'])
->limit($itemSearchData->getLimitCount())
->offset($itemSearchData->getLimitStart());
@@ -295,7 +295,7 @@ final class ClientRepository extends Repository implements ClientRepositoryInter
$query->bindValues(['name' => $search, 'description' => $search]);
}
$queryData = QueryData::build($query)->setMapClassName(Client::class);
$queryData = QueryData::build($query)->setMapClassName(ClientModel::class);
return $this->db->doSelect($queryData, true);
}