sveden-parser/src/ContingentParser/ContingentService.php

47 lines
1.4 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace SvedenParser\Parser;
use SvedenParser\Service;
final class ContingentService extends Service
{
/**
* Получить данные о численности
* @param string $html Разметка сайта вуза
* @param mixed $specialties Массив специальностей
* @param int $orgId Идентификатор организации
* @return array
*/
public function getData(string $html, array $specialties, int $orgId): array
{
$parser = new ContingentParser($html);
$contingent = $parser->getDataTable();
$this->addSpecId($contingent, $specialties);
$this->addOrgId($contingent, $orgId);
return $contingent;
}
/**
* Проверка на валидность записи численнести
* @param array $contingent Массив численности по специальностям
* @return bool
*/
public function isValidData(array $contingent): bool
{
$count = 0;
foreach ($contingent as $value) {
$count += $value['contingent'];
}
return $count ? true : false;
}
/**
*
* @param string $html
* @return string
*/
public function getLink(string $html): string
{
$parser = new ContingentParser($html);
return $parser->getLink();
}
}