From 95d854bcddc92b35ffc6aea280e13ff6f27bb3c6 Mon Sep 17 00:00:00 2001 From: Alexander Date: Mon, 2 Dec 2024 09:23:01 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D1=84=D0=B0=D0=B1=D1=80=D0=B8=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/contingent_parser.php | 13 +++++++----- src/Factory/ManagerFactory.php | 20 +++++++++++++++++++ src/Factory/ProgressBarFactory.php | 13 ++++++++++++ src/Factory/TypeManger.php | 9 +++++++++ .../ContingentManager.php | 5 +++-- src/{ => Manager}/Manager.php | 8 ++++++-- .../ContingentParser.php | 5 +++-- src/{ => Parser}/Parser.php | 2 +- .../ContingentRepository.php | 4 ++-- src/{ => Repository}/Repository.php | 3 +-- .../ContingentRow.php | 4 ++-- .../ContingentService.php | 5 +++-- src/{ => Service}/Service.php | 2 +- 13 files changed, 72 insertions(+), 21 deletions(-) create mode 100644 src/Factory/ManagerFactory.php create mode 100644 src/Factory/ProgressBarFactory.php create mode 100644 src/Factory/TypeManger.php rename src/{ContingentParser => Manager}/ContingentManager.php (69%) rename src/{ => Manager}/Manager.php (94%) rename src/{ContingentParser => Parser}/ContingentParser.php (98%) rename src/{ => Parser}/Parser.php (97%) rename src/{ContingentParser => Repository}/ContingentRepository.php (94%) rename src/{ => Repository}/Repository.php (99%) rename src/{ContingentParser => Row}/ContingentRow.php (93%) rename src/{ContingentParser => Service}/ContingentService.php (94%) rename src/{ => Service}/Service.php (97%) diff --git a/scripts/contingent_parser.php b/scripts/contingent_parser.php index 26ef74c..b1669be 100644 --- a/scripts/contingent_parser.php +++ b/scripts/contingent_parser.php @@ -1,18 +1,21 @@ value); require_once SVEDEN_PARSER . "/vendor/autoload.php"; - -$manager = new ContingentManager(); +/** @var Manager $manager */ +$manager = ManagerFactory::create(TypeManger::CONTINGENT); $sites = $manager->getSites(); -$progressBar = new ProgressBar(new ConsoleOutput(), count($sites)); +$progressBar = ProgressBarFactory::create(count($sites)); $progressBar->start(); $start = 0; $end = count($sites); diff --git a/src/Factory/ManagerFactory.php b/src/Factory/ManagerFactory.php new file mode 100644 index 0000000..6b51264 --- /dev/null +++ b/src/Factory/ManagerFactory.php @@ -0,0 +1,20 @@ + new ContingentManager(), + TypeManger::PRIEM => new PriemManager(), + TypeManger::EMPLOYEES => new EmployeesManager(), + default => null, + }; + } +} \ No newline at end of file diff --git a/src/Factory/ProgressBarFactory.php b/src/Factory/ProgressBarFactory.php new file mode 100644 index 0000000..745d8c6 --- /dev/null +++ b/src/Factory/ProgressBarFactory.php @@ -0,0 +1,13 @@ +sites = $this->getSites(); $this->httpClient = new HttpClient(); } /** @@ -103,7 +107,7 @@ abstract class Manager * @param array $params Массив сайтов, у которых нужны обновиленные URL * @return array */ - public function getSites(array $params = []): array + protected function getSites(array $params = []): array { if (!$params) { return $this->repository->getSitesFromNiimko(); diff --git a/src/ContingentParser/ContingentParser.php b/src/Parser/ContingentParser.php similarity index 98% rename from src/ContingentParser/ContingentParser.php rename to src/Parser/ContingentParser.php index 1cd0f06..48988a3 100644 --- a/src/ContingentParser/ContingentParser.php +++ b/src/Parser/ContingentParser.php @@ -3,11 +3,12 @@ * Парсер информации об образовательной организации * с её сайта с использованием микроразметки */ -namespace SvedenParser\ContingentParser; +namespace SvedenParser\Parser; use SvedenParser\Color; -use SvedenParser\Parser; use SvedenParser\Printer; +use SvedenParser\Row\ContingentRow; + final class ContingentParser extends Parser { private const TEMPLATE = '//tr[@itemprop="eduChislen"]//'; diff --git a/src/Parser.php b/src/Parser/Parser.php similarity index 97% rename from src/Parser.php rename to src/Parser/Parser.php index 72ee78d..b3e127c 100644 --- a/src/Parser.php +++ b/src/Parser/Parser.php @@ -1,5 +1,5 @@ niimko->select($sql, ['vuz', 'n', 'n', 'RU']); - } /** * Извлечение сайтов базы данных opendata diff --git a/src/ContingentParser/ContingentRow.php b/src/Row/ContingentRow.php similarity index 93% rename from src/ContingentParser/ContingentRow.php rename to src/Row/ContingentRow.php index 1b1c68e..adb9c83 100644 --- a/src/ContingentParser/ContingentRow.php +++ b/src/Row/ContingentRow.php @@ -1,5 +1,5 @@ $this->eduCode, "spec_name" => $this->eduName, "edu_level" => $this->eduLevel, - "edu_forms"=> $this->eduForm, + "edu_forms" => $this->eduForm, "contingent" => $this->contingent ]; } diff --git a/src/ContingentParser/ContingentService.php b/src/Service/ContingentService.php similarity index 94% rename from src/ContingentParser/ContingentService.php rename to src/Service/ContingentService.php index 23eb599..ee336bf 100644 --- a/src/ContingentParser/ContingentService.php +++ b/src/Service/ContingentService.php @@ -1,6 +1,7 @@