PluginProbe ʕ •ᴥ•ʔ
Search Regex / 2.4
Search Regex v2.4
trunk 1.4.12 1.4.13 1.4.14 1.4.15 1.4.16 2.0 2.0.1 2.1 2.2 2.2.1 2.3 2.3.1 2.3.2 2.3.3 2.4 2.4.1 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.1 3.1.1 3.1.2 3.2 3.3 3.3.0 3.3.1 3.4 3.4.1 3.4.2
search-regex / models / search-flags.php
search-regex / models Last commit date
match-column.php 6 years ago match-context.php 6 years ago match.php 6 years ago preset.php 5 years ago replace.php 6 years ago result.php 6 years ago search-flags.php 5 years ago search.php 5 years ago source-flags.php 5 years ago source-manager.php 5 years ago source.php 5 years ago totals.php 6 years ago
search-flags.php
69 lines
1 <?php
2
3 namespace SearchRegex;
4
5 /**
6 * Represents flags for a particular search
7 */
8 class Search_Flags {
9 /** @var String[] */
10 private $flags = [];
11
12 /**
13 * Create a Source_Flags object with an array of flag strings
14 *
15 * @param Array $flags Array of flag values.
16 */
17 public function __construct( array $flags = [] ) {
18 $allowed = [
19 'regex',
20 'case',
21 ];
22
23 $this->flags = array_filter( $flags, function( $flag ) use ( $allowed ) {
24 return array_search( $flag, $allowed, true ) !== false;
25 } );
26 }
27
28 /**
29 * Is the flag set?
30 *
31 * @param String $flag Flag to check.
32 * @return boolean true if set, false otherwise
33 */
34 public function has_flag( $flag ) {
35 return in_array( $flag, $this->flags, true );
36 }
37
38 /**
39 * Is the a regular expression search?
40 *
41 * @return boolean true if yes, false otherwise
42 */
43 public function is_regex() {
44 return $this->has_flag( 'regex' );
45 }
46
47 /**
48 * Is the a case insensitive search?
49 *
50 * @return boolean true if yes, false otherwise
51 */
52 public function is_case_insensitive() {
53 return $this->has_flag( 'case' );
54 }
55
56 /**
57 * Get all the flags
58 *
59 * @return Array Array of flags
60 */
61 public function get_flags() {
62 return $this->flags;
63 }
64
65 public function to_json() {
66 return $this->flags;
67 }
68 }
69