From 9dda665ddcf36a0bc4adc2d60416b719d08ca6d9 Mon Sep 17 00:00:00 2001 From: JaguarJack Date: Wed, 6 May 2020 17:41:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=B7=A5=E5=85=B7=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/catcher/Utils.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/extend/catcher/Utils.php b/extend/catcher/Utils.php index f1193cf..4d4fcc8 100644 --- a/extend/catcher/Utils.php +++ b/extend/catcher/Utils.php @@ -87,4 +87,26 @@ class Utils } } } + + /** + * 解析 Rule 规则 + * + * @time 2020年05月06日 + * @param $rule + * @return array + */ + public static function parseRule($rule) + { + [$controller, $action] = explode(Str::contains($rule, '@') ? '@' : '/', $rule); + + $controller = explode('\\', $controller); + + $controllerName = strtolower(array_pop($controller)); + + array_pop($controller); + + $module = array_pop($controller); + + return [$module, $controllerName, $action]; + } }