File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -57,10 +57,9 @@ private function getPatternByType($pattern)
5757 return $ pattern ;
5858 }
5959 if (is_object ($ pattern )) {
60- $ class = get_class ($ pattern );
61- if ($ class == 'SelvinOrtiz\Utils\Flux\Flux '
62- || $ class == 'VerbalExpressions\PHPVerbalExpressions\VerbalExpressions '
63- || $ class == 'MarkWilson\VerbalExpression ' ) {
60+ if (is_a ($ pattern , 'SelvinOrtiz\Utils\Flux\Flux ' )
61+ || is_a ($ pattern , 'VerbalExpressions\PHPVerbalExpressions\VerbalExpressions ' )
62+ || is_a ($ pattern , 'MarkWilson\VerbalExpression ' )) {
6463 return $ pattern ->__toString ();
6564 }
6665 }
Original file line number Diff line number Diff line change @@ -77,6 +77,19 @@ public function getSubMatchAt($index)
7777 return $ this ->element [$ index ][0 ];
7878 }
7979
80+ /**
81+ * Returns the string matching a subpattern of a pattern, giving it's index. If there
82+ * is no submatch at that index, return the default value.
83+ *
84+ * @param int $index
85+ *
86+ * @return string|mixed
87+ */
88+ public function getSubMatchOrDefaultAt ($ index , $ default = null )
89+ {
90+ return isset ($ this ->element [$ index ][0 ]) ? $ this ->element [$ index ][0 ] : $ default ;
91+ }
92+
8093 /**
8194 * Returns the offset of the string matching a subpattern of a pattern, giving it's index.
8295 *
You can’t perform that action at this time.
0 commit comments