From 048ae2c3ac463698d546ccc68ca052c4951bfb80 Mon Sep 17 00:00:00 2001 From: yggverse Date: Sat, 4 May 2024 19:26:15 +0300 Subject: [PATCH] implement environment model --- src/Model/Environment.php | 34 ++++++++++++++++++++++++++++++++++ src/crawler.php | 8 +++++--- 2 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 src/Model/Environment.php diff --git a/src/Model/Environment.php b/src/Model/Environment.php new file mode 100644 index 0000000..ae78831 --- /dev/null +++ b/src/Model/Environment.php @@ -0,0 +1,34 @@ +[^=]+)=(?.*)$/', $value, $argument)) + { + $this->_argument[mb_strtolower($argument['key'])] = (string) $argument['value']; + } + } + } + + public function get( + string $key + ): ?string + { + $key = mb_strtolower( + $key + ); + + return isset($this->_argument[$key]) ? $this->_argument[$key] + : null; + } +} \ No newline at end of file diff --git a/src/crawler.php b/src/crawler.php index 076fd14..d38b60f 100644 --- a/src/crawler.php +++ b/src/crawler.php @@ -15,12 +15,14 @@ require_once __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'; -// Init profile argument -if (empty($argv[1])) throw new \Exception; +// Init environment +$environment = new \Yggverse\Pulsar\Model\Environment( + $argv +); // Init config $config = new \Yggverse\Pulsar\Model\Config( - $argv[1] + $environment->get('config') ); $config = $config->get(); // registry only