Permalink
Browse files

Added PEAR packaging and updated to CS 1.0.2 (closes #4)

  • Loading branch information...
1 parent 8f8ee65 commit db9db4ead0861b2ac791159cf1c3c1a2e7595d64 @rodnaph rodnaph committed Jun 24, 2011
View
@@ -1,3 +1,7 @@
nbproject
-log/*
+logs/*
.DS_Store
+lib/package.xml
+catalog.xml
+*.tgz
+
View
@@ -1,18 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
-<project name="boxuk-routing" basedir="." default="test">
+<project name="boxuk-routing" basedir="." default="test-php">
<target name="init">
- <mkdir dir="log" />
+ <mkdir dir="logs" />
</target>
- <target name="test" depends="init">
- <exec command="phpunit --testdox --log-junit log/phpunit.xml tests/php" checkReturn="true" passthru="true" />
+ <target name="test-php" depends="init">
+ <exec command="phpunit --testdox --log-junit=logs/phpunit-log.xml tests/php" checkReturn="true" passthru="true" />
</target>
+
+ <target name="test-cs" depends="init">
+ <exec command="phpcs -n lib/BoxUK --standard=BoxUK > logs/checkstyle.xml"
+ checkReturn="true"
+ passthru="true" />
+ </target>
+
+ <target name="test" depends="test-php,test-cs"></target>
<target name="coverage" depends="init">
<delete dir="log/coverage" />
<exec command="phpunit --coverage-html=log/coverage tests/php/" passthru="true" checkReturn="true" />
</target>
+
+ <target name="pear-package">
+ <exec command="php package.php"
+ passthru="true"
+ checkReturn="true" />
+ <exec command="pear package lib/package.xml"
+ checkReturn="true"
+ passthru="true" />
+ </target>
</project>
View
@@ -30,7 +30,6 @@ class Routing {
/**
* Creates a new instance
*
- * @param \BoxUK\Routing\Config $config
*/
public function __construct( Config $config ) {
@@ -38,11 +38,14 @@ class Config {
private $cacheDirectory;
/**
- * @param string $routesFile
+ * Sets the routes file to parse routes from
+ *
+ * @param string $routesFile Path to routes file
*
* @throws \InvalidArgumentException
*/
public function setRoutesFile( $routesFile ) {
+
if( ! is_string( $routesFile ) ) {
throw new \InvalidArgumentException('Expected a string');
}
@@ -52,21 +55,29 @@ public function setRoutesFile( $routesFile ) {
}
$this->routesFile = $routesFile;
+
}
/**
+ * Returns the routes file that has been set, or null if it hasn't
+ *
* @return string
*/
public function getRoutesFile() {
+
return $this->routesFile;
+
}
/**
- * @param string $extension
+ * Set the URL extension to use
+ *
+ * @param string $extension eg. '.html'
*
* @throws \InvalidArgumentException
*/
public function setExtension( $extension ) {
+
if( ! is_string( $extension ) ) {
throw new \InvalidArgumentException('Expected a string');
}
@@ -75,18 +86,26 @@ public function setExtension( $extension ) {
}
+ /**
+ * Return the configured URL extension, or null
+ *
+ * @return string
+ */
public function getExtension() {
+
return $this->extension;
+
}
/**
* Sets the site domain to use
- *
- * @param string $siteDomain
*
+ * @param string $siteDomain eg. mydomain.com
+ *
* @throws \InvalidArgumentException
*/
public function setSiteDomain( $siteDomain ) {
+
if( ! is_string( $siteDomain ) ) {
throw new \InvalidArgumentException('Expected a string');
}
@@ -96,18 +115,25 @@ public function setSiteDomain( $siteDomain ) {
}
/**
+ * Returns the domain, or null if not set
+ *
* @return string
*/
public function getSiteDomain() {
+
return $this->siteDomain;
+
}
/**
- * @param string $siteWebRoot
+ * Set the web root for the application
+ *
+ * @param string $siteWebRoot eg. /base/path/
*
* @throws \InvalidArgumentException
*/
public function setSiteWebRoot( $siteWebRoot ) {
+
if( ! is_string( $siteWebRoot ) ) {
throw new \InvalidArgumentException('Expected a string');
}
@@ -117,18 +143,25 @@ public function setSiteWebRoot( $siteWebRoot ) {
}
/**
+ * Return the configured web root, or null
+ *
* @return string
*/
public function getSiteWebRoot() {
+
return $this->siteWebRoot;
+
}
/**
- * @param string $cacheDirectory
+ * Sets the directory to store cached routes
+ *
+ * @param string $cacheDirectory Path to cache directory
*
* @throws \InvalidArgumentException
*/
public function setCacheDirectory( $cacheDirectory ) {
+
if( ! is_string( $cacheDirectory ) ) {
throw new \InvalidArgumentException('Expected a string');
}
@@ -141,10 +174,14 @@ public function setCacheDirectory( $cacheDirectory ) {
}
/**
+ * Returns the cache directory if set, or null otherwise
+ *
* @return string
*/
public function getCacheDirectory() {
+
return $this->cacheDirectory;
+
}
-}
+}
@@ -39,8 +39,8 @@ public function setValue( $name, $value );
* Returns the value of a request variable, $default if it hasn't been specified
*
* @param string $name
- * @param mixed $default
- *
+ * @param string $default
+ *
* @return string
*/
public function getValue( $name, $default=null );
@@ -19,9 +19,8 @@
* Runs the router on any configured route specifications. Returns the matched
* route object if there was one, false otherwise.
*
- * @param Request $request
* @param string $url
- *
+ *
* @return Specification
*/
public function process( Request $request, $url );
@@ -31,8 +31,8 @@ public function setValue( $name, $value ) {
* Returns the value of a request variable, $default if it hasn't been specified
*
* @param string $name
- * @param mixed $default
- *
+ * @param string $default
+ *
* @return string
*/
public function getValue( $name, $default=null ) {
@@ -45,8 +45,6 @@ public function __construct( Config $config ) {
/**
* Init the router with some routes
*
- * @param array $routeSpecs
- * @param array $routeTypes
*/
public function init( array $routeSpecs, array $routeTypes ) {
@@ -58,9 +56,8 @@ public function init( array $routeSpecs, array $routeTypes ) {
/**
* Process route specs, updates the request object and returns if a match was made
*
- * @param Request $request
* @param string $url
- *
+ *
* @return Specification
*/
public function process( Request $request, $url ) {
@@ -104,9 +101,6 @@ public function process( Request $request, $url ) {
/**
* Process a single route spec and updates the request object
*
- * @param Request $request
- * @param Specification $specification
- * @param array $matches
*/
protected function processRouteSpec( Request $request, Specification $specification, array $matches ) {
@@ -133,7 +127,8 @@ protected function processRouteSpec( Request $request, Specification $specificat
/**
* Replaces shortcuts in a route (eg. ':num' and ':word') with their regexp
*
- * @param string $route
+ * @param string $route eg. '/foo/:num'
+ *
* @return string
*/
protected function buildRegExp( $route ) {
@@ -159,4 +154,4 @@ protected function buildRegExp( $route ) {
}
-}
+}
@@ -16,7 +16,7 @@
/**
* Sets the name of the php script that acts as the front controller
*
- * @param string $name
+ * @param string $name eg. 'server.php'
*/
public function setFrontController( $name );
@@ -31,7 +31,6 @@ class StandardFilter implements Filter {
/**
* Creates a new filter
*
- * @param Rewriter $rewriter
*/
public function __construct( Rewriter $rewriter ) {
@@ -43,7 +42,7 @@ public function __construct( Rewriter $rewriter ) {
/**
* Sets the name of the php script that acts as the front controller
*
- * @param string $script
+ * @param string $name eg. 'server.php'
*/
public function setFrontController( $name ) {
@@ -99,8 +98,6 @@ public function process( &$html ) {
/**
* Looks through a form to try and use hidden inputs to rewrite the form action
*
- * @param array $matches
- *
* @return string
*/
public function replaceForm( array $matches ) {
@@ -150,8 +147,6 @@ public function replaceForm( array $matches ) {
/**
* Returns a URL built from the output of getHiddenInputs()
*
- * @param array $inputs
- *
* @return string
*/
protected function getUrlFromInputs( array $inputs ) {
@@ -183,7 +178,7 @@ protected function getUrlFromInputs( array $inputs ) {
* )
*
* @param string $form
- *
+ *
* @return array
*/
protected function getHiddenInputs( $form ) {
@@ -221,8 +216,6 @@ protected function getHiddenInputs( $form ) {
* Checks the defined route specs to see if this url can be re-written
* to match one of them.
*
- * @param array $matches
- *
* @return string
*/
public function replaceAttribute( array $matches ) {
@@ -240,8 +233,6 @@ public function replaceAttribute( array $matches ) {
/**
* Replaces route urls in elements (eg. <elem>url</elem>)
*
- * @param array $matches
- *
* @return string
*/
public function replaceElement( array $matches ) {
@@ -18,8 +18,8 @@
* the old url is returned otherwise.
*
* @param string $url
- * @param bool $includeDomain (false)
- *
+ * @param bool $includeDomain
+ *
* @return string
*/
public function rewrite( $url, $includeDomain=false );
@@ -35,7 +35,7 @@ public function rewrite( $url, $includeDomain=false );
* '?foo=bar#fragment', // query string
* $specification // route spec matched
* )
- *
+ *
* @param string $url
*
* @return array
Oops, something went wrong.

0 comments on commit db9db4e

Please sign in to comment.