public function __construct(array $options = array()) { foreach ($options as $option => $value) { $this->{$option} = $value; } self::$map = App::getInstance()->getMap(); }
public function __construct($basePath) { if (!is_dir($basePath)) { throw new \InvalidArgumentException("The `{$basePath}` does not exist or is not readable"); } self::$basePath = $basePath; self::$map = App::getInstance()->getMap(); }
/** * Execute code only if debugging * @param $callable */ public static function run($msg, $jsonencode = false) { $file = App::getInstance()->getLogPath() . '/' . 'log.txt'; if (!is_file($file)) { throw new \DomainException('Path ' . $file . ' for logs doesn\'t exist'); } $fh = fopen(dirname(__FILE__) . "/../../logs/log.txt", "a"); $msg = $jsonencode ? json_encode($msg) : $msg; $msg = "[" . date('d.m.Y H:i:s') . "] " . $msg . "\r\n"; fputs($fh, $msg); fclose($fh); }
<?php require "vendor/autoload.php"; //not necessary $modules = ["Load"]; try { // get App instance $app = \ubackupparser\App::getInstance()->init($modules); // get parser and run convert listed modules $parser = $app->getParser(); $parser = $parser->run(); // get results array print_r($parser->get()); } catch (\Exception $e) { \ubackupparser\Util\Logger::run($e->getMessage()); } // or short version (modules load from config file) /* print json_encode(\ubackupparser\App::getInstance() ->init() ->getParser() ->run() ->get()); */