Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixing the AbstractTool implementation.

  • Loading branch information...
commit c6ac2b07183e5fb8bb0eb03919160895e80fa21a 1 parent cced0ad
@zyxist zyxist authored
Showing with 32 additions and 12 deletions.
  1. +32 −12 src/Opl/Autoloader/Toolset/AbstractTool.php
View
44 src/Opl/Autoloader/Toolset/AbstractTool.php
@@ -34,6 +34,11 @@
* @var array
*/
protected $extensions = array();
+ /**
+ * The namespace separator
+ * @var string
+ */
+ private $namespaceSeparator = '\\';
/**
* Registers a new top-level namespace to match.
@@ -42,25 +47,18 @@
* @param string $path The path to the namespace (without the namespace name itself).
* @param string $extension The namespace file extension.
*/
- public function addNamespace($namespace, $path = null, $extension = '.php')
+ public function addNamespace($namespace, $path, $extension = '.php')
{
if(isset($this->namespaces[(string)$namespace]))
{
throw new DomainException('The namespace '.$namespace.' is already added.');
}
- if($path !== null)
- {
- $length = strlen($path);
- if($length == 0 || $path[$length - 1] != '/')
- {
- $path .= '/';
- }
- $this->namespaces[(string)$namespace] = $path;
- }
- else
+ $length = strlen($path);
+ if($length == 0 || $path[$length - 1] != '/')
{
- $this->namespaces[(string)$namespace] = $this->defaultPath;
+ $path .= '/';
}
+ $this->namespaces[(string)$namespace] = $path;
$this->extensions[(string)$namespace] = $extension;
} // end addNamespace();
@@ -90,6 +88,28 @@ public function removeNamespace($namespace)
} // end removeNamespace();
/**
+ * Changes the namespace separator.
+ *
+ * @param string $separator The new separator
+ * @return AbstractTool Fluent interface.
+ */
+ public function setNamespaceSeparator($separator)
+ {
+ $this->namespaceSeparator = (string)$separator;
+ return $this;
+ } // end setNamespaceSeparator();
+
+ /**
+ * Returns the current namespace separator.
+ *
+ * @return string
+ */
+ public function getNamespaceSeparator()
+ {
+ return $this->namespaceSeparator;
+ } // end getNamespaceSeparator();
+
+ /**
* Translates the class name to the file name, using the algorithm from
* the Universal Loader to allow the best precision. If the class could
* not be translated, an exception is thrown.
Please sign in to comment.
Something went wrong with that request. Please try again.