1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- namespace Elgg;
- class MethodMatcher {
-
- private $type;
-
- private $method;
-
- public function __construct($type, $method) {
- $this->type = strtolower(ltrim($type, '\\'));
- $this->method = strtolower($method);
- }
-
- public function matches($subject) {
-
- if (is_string($subject)) {
- if (false === strpos($subject, '::')) {
- return false;
- }
- $subject = explode('::', $subject, 2);
- }
- if (!is_array($subject) || empty($subject[0]) || empty($subject[1]) || !is_string($subject[1])) {
- return false;
- }
- if (strtolower($subject[1]) !== $this->method) {
- return false;
- }
- if (is_object($subject[0])) {
- $subject[0] = get_class($subject[0]);
- }
- if (!is_string($subject[0])) {
- return false;
- }
- return (strtolower(ltrim($subject[0], '\\')) === $this->type);
- }
- }
|