Browse Source

implement environment model

main
yggverse 4 weeks ago
parent
commit
048ae2c3ac
  1. 34
      src/Model/Environment.php
  2. 8
      src/crawler.php

34
src/Model/Environment.php

@ -0,0 +1,34 @@ @@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
namespace Yggverse\Pulsar\Model;
class Environment
{
private array $_argument;
public function __construct(
array $argv
) {
foreach ($argv as $value)
{
if (preg_match('/^(?<key>[^=]+)=(?<value>.*)$/', $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;
}
}

8
src/crawler.php

@ -15,12 +15,14 @@ require_once __DIR__ . @@ -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

Loading…
Cancel
Save