добавил абстракций и первые варианты для парсинга результатов према

This commit is contained in:
2024-10-10 11:51:24 +03:00
parent 984f6bda0a
commit 3b6fecec6c
310 changed files with 7831 additions and 44954 deletions

View File

@@ -1,7 +1,8 @@
<?php
namespace SvedenParser\ContingentParser;
use SvedenParser\Service;
final class ContingentService
final class ContingentService extends Service
{
/**
* Получить данные о численности
@@ -10,11 +11,8 @@ final class ContingentService
* @param int $orgId Идентификатор организации
* @return array
*/
public function getContingent(
string $html,
array $specialties,
int $orgId
): array {
public function getData(string $html, array $specialties, int $orgId): array
{
$parser = new ContingentParser($html);
$contingent = $parser->getDataTable();
$this->addSpecId($contingent, $specialties);
@@ -27,7 +25,7 @@ final class ContingentService
* @param array $contingent Массив численности по специальностям
* @return bool
*/
public function isValidContingent(array $contingent): bool
public function isValidData(array $contingent): bool
{
$count = 0;
foreach ($contingent as $value) {
@@ -35,31 +33,7 @@ final class ContingentService
}
return $count ? true : false;
}
/**
* Добавить идентификатор специальности в запись численности
* @param array $contingent Массив численности по специальностям
* @param array $specialties Массив специальностей
* @return void
*/
private function addSpecId(array &$contingent, array $specialties): void
{
$specIdMap = array_column($specialties, 'spec_id', 'spec_code');
foreach ($contingent as $key => $con) {
$contingent[$key]['spec_id'] = $specIdMap[$con['spec_code']] ?? null;
}
}
/**
* Добавить идентификатор организации в запись численности
* @param array $contingent Массив численности по специальностям
* @param int $orgId Идентифиактор организации
* @return void
*/
private function addOrgId(array &$contingent, int $orgId): void
{
foreach ($contingent as &$con) {
$con['org_id'] = $orgId;
}
}
/**
*
* @param string $html