public static function readDir($dir, $return = Util::ALL, $recursive = false, $extension = NULL, $nameOnly = false, array $options = array()) {
        if (!is_dir($dir))
            return array(
                'error' => 'Directory "' . $dir . '" does not exist',
            );

        if (!is_array($extension) && !empty($extension)) {
            $extension = array($extension);
        }

        if (substr($dir, strlen($dir) - 1) !== DIRECTORY_SEPARATOR)
            $dir .= DIRECTORY_SEPARATOR;

        $toReturn = array('dirs' => array(), 'files' => array());
        try {
            foreach (scandir($dir) as $current) {
                if (in_array($current, array('.', '..')))
                    continue;

                if (is_dir($dir . $current)) {
                    if (in_array($return, array(self::DIRS_ONLY, self::ALL))) {
                        $toReturn['dirs'][] = ($nameOnly) ? $current : $dir . $current;
                    }
                    if ($recursive) {
                        $toReturn = array_merge_recursive($toReturn, self::readDir($dir . $current, self::ALL, true, $extension, $nameOnly, $options));
                    }
                } else if (is_file($dir . $current) && in_array($return, array(self::FILES_ONLY, self::ALL))) {
                    if ($extension)
                        $info = pathinfo($current);
                    if (empty($extension) || (is_array($extension) && in_array($info['extension'], $extension))) {
                        $toReturn['files'][$dir][] = ($nameOnly) ? $current : $dir . $current;
                    }
                }
            }

            if ($return == self::ALL)
                return $toReturn;
            elseif ($return == self::DIRS_ONLY)
                return $toReturn['dirs'];
            elseif ($return == self::FILES_ONLY)
                return $toReturn['files'];
        } catch (\Exception $ex) {
            throw new \Exception($ex->getMessage());
        }
    }