Permalink
Browse files

Merge branch 'composer'

  • Loading branch information...
2 parents 07bd219 + d52dd62 commit bc32591da5e054684544f229f22d5c7e5014704c @martinbean martinbean committed Sep 30, 2012
Showing with 77 additions and 11 deletions.
  1. +59 −0 composer.json
  2. +18 −11 toro.php → src/Toro.php
View
@@ -0,0 +1,59 @@
+{
+ "name": "anandkunal/ToroPHP",
+ "type": "library",
+ "description": "Toro is a PHP router for developing RESTful web applications and APIs.",
+ "keywords": [
+ "framework",
+ "php",
+ "router"
+ ],
+ "homepage": "http://github.com/anandkunal/ToroPHP",
+ "license": "MIT",
+ "authors": [
+ {
+ "name": "Kunal Anand",
+ "email": "kunal.r.anand@gmail.com",
+ "homepage": "http://kunalanand.com/",
+ "role": "Developer"
+ },
+ {
+ "name": "Danillo César de O. Melo",
+ "email": "danillos@gmail.com",
+ "homepage": "http://www.danillocesar.com.br/",
+ "role": "Contributor"
+ },
+ {
+ "name": "Martin Bean",
+ "email": "martin@martinbean.co.uk",
+ "homepage": "http://www.martinbean.co.uk",
+ "role": "Developer"
+ },
+ {
+ "name": "Robbie Coleman",
+ "homepage": "http://robbie.robnrob.com",
+ "role": "Contributor"
+ },
+ {
+ "name": "John Kurkowski",
+ "role": "Contributor"
+ },
+ {
+ "name": "Berker Peksag",
+ "homepage": "http://berkerpeksag.com",
+ "role": "Developer"
+ },
+ {
+ "name": "Jason Mooberry",
+ "homepage": "http://jasonmooberry.com/",
+ "role": "Developer"
+ }
+ ],
+ "require": {
+ "php": ">=5.0.0"
+ },
+ "autoload": {
+ "files": [
+ "src/Toro.php"
+ ]
+ }
+}
View
@@ -1,20 +1,22 @@
<?php
-class Toro {
- public static function serve($routes) {
+class Toro
+{
+ public static function serve($routes)
+ {
ToroHook::fire('before_request');
$request_method = strtolower($_SERVER['REQUEST_METHOD']);
$path_info = '/';
$path_info = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : $path_info;
$path_info = isset($_SERVER['ORIG_PATH_INFO']) ? $_SERVER['ORIG_PATH_INFO'] : $path_info;
- $discovered_handler = NULL;
+ $discovered_handler = null;
$regex_matches = array();
if (isset($routes[$path_info])) {
$discovered_handler = $routes[$path_info];
}
- elseif ($routes) {
+ else if ($routes) {
$tokens = array(
':string' => '([a-zA-Z]+)',
':number' => '([0-9]+)',
@@ -60,25 +62,29 @@ public static function serve($routes) {
ToroHook::fire('after_request');
}
- private static function xhr_request() {
+ private static function xhr_request()
+ {
return isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest';
}
}
-class ToroHook {
+class ToroHook
+{
private static $instance;
private $hooks = array();
- private function __construct() { }
- private function __clone() { }
+ private function __construct() {}
+ private function __clone() {}
- public static function add($hook_name, $fn) {
+ public static function add($hook_name, $fn)
+ {
$instance = self::get_instance();
$instance->hooks[$hook_name][] = $fn;
}
- public static function fire($hook_name, $params = NULL) {
+ public static function fire($hook_name, $params = null)
+ {
$instance = self::get_instance();
if (isset($instance->hooks[$hook_name])) {
foreach ($instance->hooks[$hook_name] as $fn) {
@@ -87,7 +93,8 @@ public static function fire($hook_name, $params = NULL) {
}
}
- public static function get_instance() {
+ public static function get_instance()
+ {
if (empty(self::$instance)) {
self::$instance = new ToroHook();
}

0 comments on commit bc32591

Please sign in to comment.