Skip to content

Commit

Permalink
master
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita Zarubin committed Jun 22, 2022
1 parent 963c1d6 commit 3611480
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
10 changes: 10 additions & 0 deletions exceptions/InvalidConstructorArrayException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace nikserg\ItcomPublicApi\exceptions;

/**
* В конструктор модели передан неправильный массив
*/
class InvalidConstructorArrayException extends Exception
{
}
14 changes: 13 additions & 1 deletion models/response/Certificate.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace nikserg\ItcomPublicApi\models\response;

use nikserg\ItcomPublicApi\exceptions\InvalidConstructorArrayException;
use nikserg\ItcomPublicApi\models\Document;
use nikserg\ItcomPublicApi\models\Field;
use nikserg\ItcomPublicApi\models\Response;
Expand Down Expand Up @@ -175,13 +176,24 @@ class Certificate extends Response
public ?string $issueDate;


/**
* @throws \nikserg\ItcomPublicApi\exceptions\InvalidConstructorArrayException
*/
protected function prepareResponseContent(array $responseContent): array
{
if (empty($responseContent)) {
throw new InvalidConstructorArrayException('Передан пустой массив для создания заявки на сертификат');
}
$responseContent['isGKFH'] = boolval($responseContent['isGKFH'] ?? false);
$responseContent['isMinor'] = boolval($responseContent['isMinor'] ?? false);
$responseContent['isMep'] = boolval($responseContent['isMep'] ?? false);
$responseContent['isForeignCompany'] = boolval($responseContent['isForeignCompany'] ?? false);
$responseContent['noColorScan'] = boolval($responseContent['noColorScan'] ?? false);

if (!isset($responseContent['status'])) {
throw new InvalidConstructorArrayException('В массиве для создания заявки на сертификат нет ключа status. Передан массив ' . print_r($responseContent,
true));
}
$responseContent['status'] = new Status($responseContent['status']);
$responseContent['isForeigner'] = boolval($responseContent['isForeigner'] ?? false);
$responseContent['isNewProcess'] = boolval($responseContent['isNewProcess'] ?? false);
Expand Down Expand Up @@ -252,11 +264,11 @@ public function getDocumentById(string $documentId): ?Document
return $document;
}
}

return null;
}



/**
* Получить значение поля анкеты, если оно существует (и если значение задано)
*
Expand Down

0 comments on commit 3611480

Please sign in to comment.