Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixing the AbstractTool implementation.

  • Loading branch information...
commit c6ac2b07183e5fb8bb0eb03919160895e80fa21a 1 parent cced0ad
Tomasz Jędrzejewski authored June 30, 2011

Showing 1 changed file with 32 additions and 12 deletions. Show diff stats Hide diff stats

  1. 44  src/Opl/Autoloader/Toolset/AbstractTool.php
44  src/Opl/Autoloader/Toolset/AbstractTool.php
@@ -34,6 +34,11 @@
34 34
 	 * @var array
35 35
 	 */
36 36
 	protected $extensions = array();
  37
+	/**
  38
+	 * The namespace separator
  39
+	 * @var string
  40
+	 */
  41
+	private $namespaceSeparator = '\\';
37 42
 	
38 43
 	/**
39 44
 	 * Registers a new top-level namespace to match.
@@ -42,25 +47,18 @@
42 47
 	 * @param string $path The path to the namespace (without the namespace name itself).
43 48
 	 * @param string $extension The namespace file extension.
44 49
 	 */
45  
-	public function addNamespace($namespace, $path = null, $extension = '.php')
  50
+	public function addNamespace($namespace, $path, $extension = '.php')
46 51
 	{
47 52
 		if(isset($this->namespaces[(string)$namespace]))
48 53
 		{
49 54
 			throw new DomainException('The namespace '.$namespace.' is already added.');
50 55
 		}
51  
-		if($path !== null)
52  
-		{
53  
-			$length = strlen($path);
54  
-			if($length == 0 || $path[$length - 1] != '/')
55  
-			{
56  
-				$path .= '/';
57  
-			}
58  
-			$this->namespaces[(string)$namespace] = $path;
59  
-		}
60  
-		else
  56
+		$length = strlen($path);
  57
+		if($length == 0 || $path[$length - 1] != '/')
61 58
 		{
62  
-			$this->namespaces[(string)$namespace] = $this->defaultPath;
  59
+			$path .= '/';
63 60
 		}
  61
+		$this->namespaces[(string)$namespace] = $path;
64 62
 		$this->extensions[(string)$namespace] = $extension;
65 63
 	} // end addNamespace();
66 64
 
@@ -90,6 +88,28 @@ public function removeNamespace($namespace)
90 88
 	} // end removeNamespace();
91 89
 	
92 90
 	/**
  91
+	 * Changes the namespace separator.
  92
+	 * 
  93
+	 * @param string $separator The new separator
  94
+	 * @return AbstractTool Fluent interface.
  95
+	 */
  96
+	public function setNamespaceSeparator($separator)
  97
+	{
  98
+		$this->namespaceSeparator = (string)$separator;
  99
+		return $this;
  100
+	} // end setNamespaceSeparator();
  101
+	
  102
+	/**
  103
+	 * Returns the current namespace separator.
  104
+	 * 
  105
+	 * @return string
  106
+	 */
  107
+	public function getNamespaceSeparator()
  108
+	{
  109
+		return $this->namespaceSeparator;
  110
+	} // end getNamespaceSeparator();
  111
+	
  112
+	/**
93 113
 	 * Translates the class name to the file name, using the algorithm from
94 114
 	 * the Universal Loader to allow the best precision. If the class could
95 115
 	 * not be translated, an exception is thrown.

0 notes on commit c6ac2b0

Please sign in to comment.
Something went wrong with that request. Please try again.