PluginProbe
Plugin Check (PCP) / trunk
Plugin Check (PCP) vtrunk
2.1.0 trunk 0.1 0.2.0 0.2.1 0.2.2 0.2.3 1.0.0 1.0.1 1.0.2 1.1.0 1.2.0 1.3.0 1.3.1 1.4.0 1.5.0 1.6.0 1.7.0 1.8.0 1.9.0 2.0.0 ci-artifacts
plugin-check / includes / Checker / Check_Collection.php

Check_Collection.php in Plugin Check (PCP) trunk, at includes/Checker/Check_Collection.php

89 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Class WordPress\Plugin_Check\Checker\Check_Collection
4 *
5 * @package plugin-check
6 */
7
8 namespace WordPress\Plugin_Check\Checker;
9
10 use ArrayAccess;
11 use Countable;
12 use IteratorAggregate;
13 use WordPress\Plugin_Check\Checker\Exception\Invalid_Check_Slug_Exception;
14
15 /**
16 * Check Collection interface.
17 *
18 * @since 1.0.0
19 */
20 interface Check_Collection extends ArrayAccess, Countable, IteratorAggregate {
21
22 /**
23 * Returns the raw indexed array representation of this collection.
24 *
25 * @since 1.0.0
26 *
27 * @return array The indexed array of check objects.
28 */
29 public function to_array(): array;
30
31 /**
32 * Returns the raw map of check slugs and their check objects as a representation of this collection.
33 *
34 * @since 1.0.0
35 *
36 * @return array Map of `$check_slug => $check_obj` pairs.
37 */
38 public function to_map(): array;
39
40 /**
41 * Returns a new check collection containing the subset of checks based on the given check filter function.
42 *
43 * @since 1.0.0
44 *
45 * @phpstan-param callable(Check,string): bool $filter_fn
46 *
47 * @param callable $filter_fn Filter function that accepts a Check object and a Check slug and
48 * should return a boolean for whether to include the check in the new collection.
49 * @return Check_Collection New check collection, effectively a subset of this one.
50 */
51 public function filter( callable $filter_fn ): Check_Collection;
52
53 /**
54 * Returns a new check collection containing the subset of checks based on the given check slugs.
55 *
56 * If the given list is empty, the same collection will be returned without any change.
57 *
58 * @since 1.0.0
59 *
60 * @param array $check_slugs List of slugs to limit to only those. If empty, the same collection is returned.
61 * @return Check_Collection New check collection, effectively a subset of this one.
62 */
63 public function include( array $check_slugs ): Check_Collection;
64
65 /**
66 * Returns a new check collection excluding the provided checks.
67 *
68 * If the given list is empty, the same collection will be returned without any change.
69 *
70 * @since 1.0.0
71 *
72 * @param array $check_slugs List of slugs to exclude. If empty, the same collection is returned.
73 * @return Check_Collection New check collection, effectively a subset of this one.
74 */
75 public function exclude( array $check_slugs ): Check_Collection;
76
77 /**
78 * Throws an exception if any of the given check slugs are not present, or returns the same collection otherwise.
79 *
80 * @since 1.0.0
81 *
82 * @param array $check_slugs List of slugs to limit to only those. If empty, the same collection is returned.
83 * @return Check_Collection The unchanged check collection.
84 *
85 * @throws Invalid_Check_Slug_Exception Thrown when any of the given check slugs is not present in the collection.
86 */
87 public function require( array $check_slugs ): Check_Collection;
88 }
89