diff --git a/src/Components/Validator.php b/src/Components/Validator.php index ee39f6c..9ff9d9f 100644 --- a/src/Components/Validator.php +++ b/src/Components/Validator.php @@ -153,7 +153,7 @@ public function getNewModel() { * @return integer */ public function getRelationType() { - if (in_array($this->_type, ['string', 'integer', 'float', 'boolean', '\DateTime'])) { + if (in_array($this->_type, ['string', 'integer', 'float', 'boolean', '\DateTime']) || (substr($this->_type, -2) == '[]' && strlen($this->_type) == 2)) { return self::TYPE_VALUE; } else if (substr($this->_type, -2) == '[]') { return self::TYPE_MANY; diff --git a/src/Helpers/DocGen/Generator.php b/src/Helpers/DocGen/Generator.php index 75049ad..3420f37 100644 --- a/src/Helpers/DocGen/Generator.php +++ b/src/Helpers/DocGen/Generator.php @@ -10,13 +10,18 @@ class Generator extends Command { + /** + * @var string + */ + public $root; + public function configure() { $this->setName('docgen')->setDescription('Scraper for model data'); $this->addArgument('namespace', InputArgument::OPTIONAL, 'Directory of models (relative to root / src directory)?', 'Models'); } public function execute(InputInterface $input, OutputInterface $output) { - $root = realpath(dirname(__FILE__) . '/../../') . DIRECTORY_SEPARATOR . 'Models' . DIRECTORY_SEPARATOR; + $root = $this->root . DIRECTORY_SEPARATOR . '/src/' . DIRECTORY_SEPARATOR . 'Models' . DIRECTORY_SEPARATOR; $directory = new \RecursiveDirectoryIterator($root); $iterator = new \RecursiveIteratorIterator($directory); $regex = new \RegexIterator($iterator, '/^.+\.php$/i', \RecursiveRegexIterator::GET_MATCH); diff --git a/src/cli.php b/src/cli.php index 0267674..dbf4496 100644 --- a/src/cli.php +++ b/src/cli.php @@ -1,11 +1,14 @@ #!/usr/bin/env php add(new Generator()); + +$generator = new Generator(); +$generator->root = dirname(__FILE__); +$application->add($generator); $application->run(); \ No newline at end of file