1. Go to this page and download the library: Download ex3mm/kontur-focus library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ex3mm / kontur-focus example snippets
declare(strict_types=1);
use Ex3mm\KonturFocus\Config\KonturFocusConfig;
use Ex3mm\KonturFocus\KonturFocusManager;
$config = KonturFocusConfig::fromArray(
use Ex3mm\KonturFocus\Laravel\Facades\KonturFocus;
// Вариант 1: Упрощённый синтаксис (рекомендуется)
$result = KonturFocus::getReq(inn: '7707083893');
// Вариант 2: Fluent API для гибкой настройки
$result = KonturFocus::req()
->inn('7707083893')
->asArray()
->get();
use Ex3mm\KonturFocus\Laravel\Facades\KonturFocus;
// Получить данные по ИНН
$result = KonturFocus::getReq(inn: '7707083893');
// Получить данные по ОГРН
$result = KonturFocus::getEgrDetails(ogrn: '1027700132195');
// Можно передать оба параметра
$result = KonturFocus::getLegalAnalytics(
inn: '7707083893',
ogrn: '1027700132195'
);
// Все методы возвращают CollectionResponse
$result->items; // array<DTO>
$result->first(); // DTO|null
$result->isEmpty(); // bool
$result = KonturFocus::getCompanyAffiliationsTypes(
inn: '6663003127',
skip: 0,
take: 100,
affiliationType: 2,
);
$affiliate = $result->first();
$affiliate->inn; // ИНН связанной организации или ИП
$affiliate->name; // Наименование организации или ФИО ИП
$affiliate->status; // Статус организации или ИП
$affiliate->connections; // Типы связей и роли участников
$result = KonturFocus::getFssp(
inn: '7707083893',
skip: 1000,
);
$company = $result->first();
$company->updateDate; // Дата актуальности данных
$company->fssp; // array<FsspDataDto>|null
$result = $focus->req()
->inn('7707083893')
->asDto()
->get();
// $result - это CollectionResponse с полями:
// - items: array<DTO> - массив DTO объектов
// - raw: string - сырой JSON ответ
// - total: int - количество элементов
// Получить первый элемент
$dto = $result->first();
// Проверить пустоту
if ($result->isEmpty()) {
// нет данных
}
// Получить массив DTO
$items = $result->toArray();
use Ex3mm\KonturFocus\Exceptions\EmptyResponseException;
try {
$result = $focus->req()
->inn('7707083893')
->asDto()
->throwOnEmpty() // выбросит EmptyResponseException если total === 0
->get();
} catch (EmptyResponseException $e) {
// обработка пустого результата
}
$result = $focus->req()->inn('7707083893')->asDto()->get();
// Доступные методы:
$result->items; // array<DTO> - массив DTO объектов
$result->raw; // string - сырой JSON ответ
$result->total; // int - количество элементов
$result->first(); // DTO|null - первый элемент или null
$result->toArray(); // array<DTO> - массив DTO
$result->count(); // int - количество элементов
$result->isEmpty(); // bool - проверка на пустоту
$result->isNotEmpty(); // bool - проверка на наличие данных
use Ex3mm\KonturFocus\DTOs\Attributes\ArrayOf;
final readonly class ParentDto
{
/**
* @param array<ChildDto> $children
*/
public function __construct(
#[ArrayOf(ChildDto::class)]
public array $children,
) {
}
}