Skip to content

Commit

Permalink
added suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
gevorgmansuryan committed Jul 3, 2018
1 parent cadf24e commit 2532525
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/GroupRuleInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ public function domain($domain);
*/
public function prefix($prefix);

/**
* @param $suffix
* @return GroupRuleInterface
*/
public function suffix($suffix);

/**
* @param array $defaults
* @return GroupRuleInterface
Expand Down
11 changes: 11 additions & 0 deletions src/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,15 @@ public static function prefix($prefix)
$group->prefix($prefix);
return $group;
}

/**
* @param $suffix
* @return GroupRuleInterface
*/
public static function suffix($suffix)
{
$group = new RuleGroup();
$group->suffix($suffix);
return $group;
}
}
5 changes: 4 additions & 1 deletion src/Rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,12 @@ public function getConfig()
public function make(array $groups = [])
{
$prefix = [];
$suffix = [];
$routePrefix = [];
$domain = [];
$middleware = [];
foreach ($groups as $group) {
$suffix[] = $group->suffix;
$prefix[] = $group->prefix;
$domain[] = $group->domain;
$routePrefix[] = $group->routePrefix;
Expand All @@ -80,7 +82,8 @@ public function make(array $groups = [])
$this->config = [
'pattern' => $prefix,
'route' => '/' . $route,
'verb' => $this->verbs
'verb' => $this->verbs,
'suffix' => implode('', $suffix)
];

return $this;
Expand Down
10 changes: 10 additions & 0 deletions src/RuleGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ class RuleGroup extends BaseObject implements GroupRuleInterface
* @var string
*/
public $prefix;
/**
* @var string
*/
public $suffix;

public $defaults = [];

Expand Down Expand Up @@ -53,6 +57,12 @@ public function prefix($prefix)
return $this;
}

public function suffix($suffix)
{
$this->suffix = $suffix;
return $this;
}

public function defaults(array $defaults)
{
$this->defaults = $defaults;
Expand Down

0 comments on commit 2532525

Please sign in to comment.