Skip to content

Commit aca4c57

Browse files
committed
Merge branch 'release/0.6.5'
2 parents 68f3930 + 168543b commit aca4c57

File tree

6 files changed

+52
-26
lines changed

6 files changed

+52
-26
lines changed

README.md

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
# Routing
1+
[![Build Status](https://app.travis-ci.com/Neuron-PHP/routing.svg?token=F8zCwpT7x7Res7J2N4vF&branch=master)](https://app.travis-ci.com/Neuron-PHP/routing)
2+
# Neuron-PHP Routing
23

3-
The neuron router is a lightweight router/dispatcher is the vein of Ruby's Sinatra
4+
## Overview
5+
6+
The neuron router is a lightweight router/dispatcher is the vein of Ruby's Sinatra
47
or Python's Flask. It allows for a very quick method for creating an app
58
using restful routes or to add them to an existing application.
69

@@ -11,21 +14,12 @@ using restful routes or to add them to an existing application.
1114

1215
## Installation
1316

14-
The best way to install Notion is via [Composer](http://getcomposer.org)
15-
16-
Our package is located [here](https://packagist.org/packages/neuron-php/routing)
17-
18-
Install Composer
19-
20-
curl -sS https://getcomposer.org/installer | php
17+
Install php composer from https://getcomposer.org/
2118

22-
Add the Routing Package
19+
Install the neuron routing component:
2320

24-
php composer.phar require neuron-php/routing
21+
composer require neuron-php/routing
2522

26-
Install Later Updates
27-
28-
composer.phar update
2923

3024
## .htaccess
3125
This example .htaccess file shows how to get and pass the route
@@ -43,7 +37,7 @@ Here is an example of a fully functional application that processes
4337
several routes including one with a variable.
4438

4539
<?php
46-
require_once '../vendor/autoload.php';
40+
require_once 'vendor/autoload.php';
4741

4842
Route::get( '/',
4943
function()
@@ -85,3 +79,7 @@ several routes including one with a variable.
8579

8680
If present, the extra element is merged into the parameters array
8781
before it is passed to the routes closure.
82+
83+
# More Information
84+
85+
You can read more about the Neuron components at [neuronphp.com](http://neuronphp.com)

VERSIONLOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.6.5
2+
3+
## 0.6.4
4+
15
## 0.6.3 2024-11-27
26
* Updated route signatures.
37
* Added logging.

src/Routing/Request.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function getRoute()
6060
* @param $Name
6161
* @return mixed
6262
*/
63-
public function getUrlParam( $Name )
63+
public function getUrlParam( $Name ): mixed
6464
{
6565
return $this->_Get->filterScalar( $Name );
6666
}
@@ -69,7 +69,7 @@ public function getUrlParam( $Name )
6969
* @param $Name
7070
* @return mixed
7171
*/
72-
public function getPostParam( $Name )
72+
public function getPostParam( $Name ): mixed
7373
{
7474
return $this->_Post->filterScalar( $Name );
7575
}
@@ -78,7 +78,7 @@ public function getPostParam( $Name )
7878
* @param $Name
7979
* @return mixed
8080
*/
81-
public function getRequest( $Name )
81+
public function getRequest( $Name ): mixed
8282
{
8383
$Result = $this->get( $Name );
8484

src/Routing/Route.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,58 @@
77
*/
88
class Route
99
{
10+
/**
11+
* @throws \Exception
12+
*/
1013
public static function delete( string $Route, $Function ) : RouteMap
1114
{
15+
/** @var Router $Router */
1216
$Router = Router::getInstance();
1317

1418
return $Router->delete( $Route, $Function );
1519
}
1620

21+
/**
22+
* @throws \Exception
23+
*/
1724
public static function get( string $Route, $Function ) : RouteMap
1825
{
26+
/** @var Router $Router */
1927
$Router = Router::getInstance();
2028

2129
return $Router->get( $Route, $Function );
2230
}
2331

32+
/**
33+
* @throws \Exception
34+
*/
2435
public static function post( string $Route, $Function ) : RouteMap
2536
{
37+
/** @var Router $Router */
2638
$Router = Router::getInstance();
2739

2840
return $Router->post( $Route, $Function );
2941
}
3042

43+
/**
44+
* @throws \Exception
45+
*/
3146
public static function put( string $Route, $Function ) : RouteMap
3247
{
48+
/** @var Router $Router */
3349
$Router = Router::getInstance();
3450

3551
return $Router->put( $Route, $Function );
3652
}
3753

54+
/**
55+
* @throws \Exception
56+
*/
3857
public static function dispatch( array $Params )
3958
{
40-
return Router::getInstance()->run( $Params );
59+
/** @var Router $Router */
60+
$Router = Router::getInstance();
61+
62+
return $Router->run( $Params );
4163
}
4264
}

src/Routing/RouteMap.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Neuron\Routing;
44

5+
use Exception;
6+
57
class RouteMap
68
{
79
public string $Path;
@@ -16,14 +18,14 @@ class RouteMap
1618
* @param $Path string route path i.e. /part/new or /part/:id
1719
* @param $Function callable the function to call on a matching route.
1820
* @param $Filter string the name of the filter to match with this route.
19-
* @throws \Exception
21+
* @throws Exception
2022
*/
2123

2224
public function __construct( string $Path, callable $Function, string $Filter = '' )
2325
{
2426
if( !is_callable( $Function ) )
2527
{
26-
throw new \Exception( 'RouteMap: function not callable.' );
28+
throw new Exception( 'RouteMap: function not callable.' );
2729
}
2830

2931
$this->Path = $Path;
@@ -127,10 +129,10 @@ public function setName( $Name ) : RouteMap
127129
/**
128130
* Extracts the template array from the route definition.
129131
* @return array
130-
* @throws \Exception
132+
* @throws Exception
131133
*/
132134

133-
public function parseParams()
135+
public function parseParams(): array
134136
{
135137
$Details = [];
136138

@@ -167,7 +169,7 @@ public function parseParams()
167169
* @throws RouteParamException
168170
*/
169171

170-
protected function checkForDuplicateParams( $Param, $Params )
172+
protected function checkForDuplicateParams( $Param, $Params ): void
171173
{
172174
foreach( $Params as $Current )
173175
{
@@ -181,7 +183,7 @@ protected function checkForDuplicateParams( $Param, $Params )
181183
/**
182184
* @param Router $Router
183185
* @return mixed
184-
* @throws \Exception
186+
* @throws Exception
185187
*/
186188
public function execute( Router $Router ): mixed
187189
{

version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"major":0,"minor":6,"patch":3,"build":0}
1+
{"major":0,"minor":6,"patch":5,"build":0}

0 commit comments

Comments
 (0)