Skip to content

Commit

Permalink
Merge pull request #17 from BenRutlandWeb/feature/support
Browse files Browse the repository at this point in the history
Feature/support
  • Loading branch information
BenRutlandWeb authored Feb 13, 2021
2 parents 0ada45e + ea03195 commit c7badf6
Show file tree
Hide file tree
Showing 18 changed files with 2,444 additions and 43 deletions.
23 changes: 3 additions & 20 deletions Radiate/Console/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Radiate\Console;

use Exception;
use Radiate\Support\Facades\Str;

class Parser
{
Expand Down Expand Up @@ -76,7 +77,7 @@ protected static function parseArgument(string $token): array
[$token, $description] = static::extractDescription($token);

switch (true) {
case static::endsWith($token, '?'):
case Str::endsWith($token, '?'):
return [
'type' => 'positional',
'name' => trim($token, '?'),
Expand Down Expand Up @@ -110,7 +111,7 @@ protected static function parseOption(string $token): array
[$token, $description] = static::extractDescription($token);

switch (true) {
case static::endsWith($token, '='):
case Str::endsWith($token, '='):
return [
'type' => 'assoc',
'name' => trim($token, '='),
Expand Down Expand Up @@ -145,22 +146,4 @@ protected static function extractDescription(string $token): array

return count($parts) === 2 ? $parts : [$token, ''];
}

/**
* Determine if a string ends with a substring
*
* @param string $haystack
* @param string $needle
* @return void
*/
protected static function endsWith(string $haystack, string $needle)
{
$length = strlen($needle);
if (
!$length
) {
return true;
}
return substr($haystack, -$length) === $needle;
}
}
2 changes: 1 addition & 1 deletion Radiate/Foundation/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
use Radiate\Foundation\Providers\ConsoleServiceProvider;
use Radiate\Filesystem\FilesystemServiceProvider;
use Radiate\Http\Request;
use Radiate\Routing\Pipeline;
use Radiate\Routing\RoutingServiceProvider;
use Radiate\Support\Facades\Facade;
use Radiate\Support\Pipeline;
use Radiate\View\ViewServiceProvider;
use RuntimeException;
use Throwable;
Expand Down
5 changes: 0 additions & 5 deletions Radiate/Mail/MailServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Radiate\Mail;

use Parsedown;
use Radiate\Support\ServiceProvider;

class MailServiceProvider extends ServiceProvider
Expand All @@ -17,10 +16,6 @@ public function register(): void
$this->app->singleton('mailer', function ($app) {
return new Mailer($app['events']);
});

$this->app->singleton('markdown', function () {
return new Parsedown();
});
}

/**
Expand Down
6 changes: 3 additions & 3 deletions Radiate/Mail/Mailable.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Radiate\Mail;

use Radiate\Support\Facades\App;
use Radiate\Support\Facades\Str;
use Radiate\Support\Facades\View;
use ReflectionClass;
use ReflectionProperty;
Expand Down Expand Up @@ -195,7 +195,7 @@ public function text(string $path, array $data = []): self
*/
public function view(string $path, array $data = []): self
{
$this->html = View::view($path, $this->buildViewData($data));
$this->html = View::make($path, $this->buildViewData($data));

return $this;
}
Expand All @@ -211,7 +211,7 @@ public function markdown(string $path, array $data = []): self
{
$this->text($path, $data);

$this->html = App::get('markdown')->text($this->text);
$this->html = Str::markdown($this->text);

return $this;
}
Expand Down
1 change: 1 addition & 0 deletions Radiate/Routing/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Radiate\Foundation\Application;
use Radiate\Http\Request;
use Radiate\Support\Pipeline;
use Throwable;

abstract class Route
Expand Down
26 changes: 13 additions & 13 deletions Radiate/Routing/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,19 @@ public function __construct(Dispatcher $events, Application $app)
*
* @param string $uri
* @param mixed $action
* @return void
* @return \Radiate\Routing\Route
*/
public function ajax(string $uri, $action)
{
return $this->addRoute(new AjaxRoute('AJAX', $uri, $action));
}

/**
* Create an GET route
* Create a GET route
*
* @param string $uri
* @param mixed $action
* @return void
* @return \Radiate\Routing\Route
*/
public function get(string $uri, $action)
{
Expand All @@ -86,7 +86,7 @@ public function get(string $uri, $action)
*
* @param string $uri
* @param mixed $action
* @return void
* @return \Radiate\Routing\Route
*/
public function post(string $uri, $action)
{
Expand All @@ -98,7 +98,7 @@ public function post(string $uri, $action)
*
* @param string $uri
* @param mixed $action
* @return void
* @return \Radiate\Routing\Route
*/
public function put(string $uri, $action)
{
Expand All @@ -110,7 +110,7 @@ public function put(string $uri, $action)
*
* @param string $uri
* @param mixed $action
* @return void
* @return \Radiate\Routing\Route
*/
public function patch(string $uri, $action)
{
Expand All @@ -122,32 +122,32 @@ public function patch(string $uri, $action)
*
* @param string $uri
* @param mixed $action
* @return void
* @return \Radiate\Routing\Route
*/
public function delete(string $uri, $action)
{
return $this->addRoute(new RestRoute('DELETE', $uri, $action));
}

/**
* Create an route with any method
* Create a route with any method
*
* @param string $uri
* @param mixed $action
* @return void
* @return \Radiate\Routing\Route
*/
public function any(string $uri, $action)
{
return $this->addRoute(new RestRoute(['GET', 'HEAD', 'POST', 'PUT', 'PATCH', 'DELETE'], $uri, $action));
}

/**
* Create an route matching the given methods
* Create a route matching the given methods
*
* @param array $methods
* @param string $uri
* @param mixed $action
* @return void
* @return \Radiate\Routing\Route
*/
public function matches(array $methods, string $uri, $action)
{
Expand Down Expand Up @@ -190,8 +190,8 @@ public function resource(string $uri, string $action, array $methods = ['index',
/**
* Regsiter the route in the router
*
* @param Radiate\Routing\Route $route
* @return void
* @param \Radiate\Routing\Route $route
* @return \Radiate\Routing\Route
*/
public function addRoute(Route $route)
{
Expand Down
Loading

0 comments on commit c7badf6

Please sign in to comment.