From 837fca688670d6c4ed878143cd41e05f8298a8b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Goetz?= Date: Tue, 7 Nov 2017 23:17:05 +0100 Subject: [PATCH] Small refactoring and documentation fix --- README.md | 2 +- libs/Daux.php | 2 +- libs/DauxHelper.php | 25 ++++++++++++++++--------- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 6b6593a..ede5245 100755 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![Build Status](https://img.shields.io/travis/dauxio/daux.io/master.svg?style=flat-square)](https://travis-ci.org/dauxio/daux.io) [![Coverage Status](https://img.shields.io/scrutinizer/coverage/g/dauxio/daux.io.svg?style=flat-square)](https://scrutinizer-ci.com/g/dauxio/daux.io/code-structure) [![Quality Score](https://img.shields.io/scrutinizer/g/dauxio/daux.io.svg?style=flat-square)](https://scrutinizer-ci.com/g/dauxio/daux.io) -[![Total Downloads](https://img.shields.io/packagist/dt/dauxio/daux.io.svg?style=flat-square)](https://packagist.org/packages/dauxio/daux.io) +[![Total Downloads](https://img.shields.io/packagist/dt/daux/daux.io.svg?style=flat-square)](https://packagist.org/packages/daux/daux.io) **Daux.io** is a documentation generator that uses a simple folder structure and Markdown files to create custom documentation on the fly. It helps you create great looking documentation in a developer friendly way. diff --git a/libs/Daux.php b/libs/Daux.php index 9e46dc2..c0361df 100644 --- a/libs/Daux.php +++ b/libs/Daux.php @@ -72,7 +72,7 @@ class Daux // Read command line overrides $override_file = $this->getConfigurationOverride($override_file); - if ($override_file != null) { + if ($override_file !== null) { $params->setConfigurationOverrideFile($override_file); $this->loadConfiguration($override_file); } diff --git a/libs/DauxHelper.php b/libs/DauxHelper.php index dc284fe..ca5b13d 100644 --- a/libs/DauxHelper.php +++ b/libs/DauxHelper.php @@ -469,11 +469,19 @@ class DauxHelper return '' !== $parts['root']; } + public static function getAbsolutePath($path) { + if (DauxHelper::isAbsolutePath($path)) { + return $path; + } + + return getcwd() . '/' . $path; + } + /** - * @param $path - * @param $basedir - * @param $var - * @param $type + * @param string|null $path + * @param string $basedir + * @param string $var The constant name to check + * @param "dir"|"file" $type * @return false|null|string */ public static function findLocation($path, $basedir, $var, $type) { @@ -483,18 +491,17 @@ class DauxHelper return $env; } + // If Path is explicitly null, it's useless to go further if ($path == null) { return null; } + // Check if it's relative to the current directory or an absolute path if (DauxHelper::is($path, $type)) { - if (DauxHelper::isAbsolutePath($path)) { - return $path; - } - - return getcwd() . '/' . $path; + return DauxHelper::getAbsolutePath($path); } + // Check if it exists relative to Daux's root $newPath = $basedir . DIRECTORY_SEPARATOR . $path; if (DauxHelper::is($newPath, $type)) { return $newPath;