| 1 |
<?php |
| 2 |
|
| 3 |
namespace FakerPress\Module; |
| 4 |
|
| 5 |
use FakerPress\ThirdParty\Faker\Generator; |
| 6 |
use FakerPress\ThirdParty\Faker\Provider\Base; |
| 7 |
|
| 8 |
interface Interface_Module { |
| 9 |
|
| 10 |
/** |
| 11 |
* Gets the slug of the module. |
| 12 |
* |
| 13 |
* @since 0.6.0 |
| 14 |
* |
| 15 |
* @return string |
| 16 |
*/ |
| 17 |
public static function get_slug(): string; |
| 18 |
|
| 19 |
/** |
| 20 |
* Gets the key that stores the flag for an item created in FakerPress. |
| 21 |
* |
| 22 |
* @since 0.6.0 |
| 23 |
* |
| 24 |
* @return string |
| 25 |
*/ |
| 26 |
public static function get_flag(): string; |
| 27 |
|
| 28 |
/** |
| 29 |
* Any module requires by default the publish_posts permissions. |
| 30 |
* |
| 31 |
* @since 0.6.0 |
| 32 |
* |
| 33 |
* @return string |
| 34 |
*/ |
| 35 |
public static function get_permission_required(): string; |
| 36 |
|
| 37 |
/** |
| 38 |
* Amount of instances of the module that are allowed to be generated in one single request. |
| 39 |
* |
| 40 |
* @since 0.6.0 |
| 41 |
* |
| 42 |
* @return int |
| 43 |
*/ |
| 44 |
public function get_amount_allowed(): int; |
| 45 |
|
| 46 |
/** |
| 47 |
* When dealing with any module there will be a hook method that will bind any WordPress hook needed. |
| 48 |
* |
| 49 |
* @since 0.6.0 |
| 50 |
* |
| 51 |
* @return void |
| 52 |
*/ |
| 53 |
public function hook(): void; |
| 54 |
|
| 55 |
/** |
| 56 |
* Pulls an array of the class names for all the Dependencies of this module, normally a list of classes |
| 57 |
* that will extend `Faker\Provider\Base`. |
| 58 |
* |
| 59 |
* @since 0.6.0 |
| 60 |
* |
| 61 |
* @return array |
| 62 |
*/ |
| 63 |
public function get_dependencies(): array; |
| 64 |
|
| 65 |
/** |
| 66 |
* Which is the base provider that will be used to generate data for this provider. |
| 67 |
* |
| 68 |
* @since 0.6.0 |
| 69 |
* |
| 70 |
* @return string |
| 71 |
*/ |
| 72 |
public function get_provider_class(): string; |
| 73 |
|
| 74 |
/** |
| 75 |
* Gets the Faker Generator used on this module. |
| 76 |
* |
| 77 |
* @since 0.6.0 |
| 78 |
* |
| 79 |
* @return Generator |
| 80 |
*/ |
| 81 |
public function get_faker(): Generator; |
| 82 |
|
| 83 |
/** |
| 84 |
* Method that sets the data for an individual generator method. |
| 85 |
* |
| 86 |
* @since 0.6.4 |
| 87 |
* |
| 88 |
* @param array|string $key Name of a particular method or a set of methods. |
| 89 |
* @param ...mixed $data Any number of arguments. |
| 90 |
* |
| 91 |
* @return Interface_Module |
| 92 |
*/ |
| 93 |
public function set( $key ): Interface_Module; |
| 94 |
|
| 95 |
/** |
| 96 |
* Use this method to save the fake data to the database |
| 97 |
* |
| 98 |
* @since 0.6.0 |
| 99 |
* |
| 100 |
* @return int|bool|\WP_Error Should return an error, or the $wpdb->insert_id or bool for the state |
| 101 |
*/ |
| 102 |
public function save( bool $reset = true ); |
| 103 |
|
| 104 |
/** |
| 105 |
* Use this method to delete a given item from this Module. |
| 106 |
* |
| 107 |
* @since 0.6.0 |
| 108 |
* |
| 109 |
* @param int|\WP_Post|string $item What are we deleting |
| 110 |
* |
| 111 |
* @return bool|\WP_Error |
| 112 |
*/ |
| 113 |
public static function delete( $item ); |
| 114 |
|
| 115 |
/** |
| 116 |
* Use this method to fetch all items created from a given module. |
| 117 |
* |
| 118 |
* @since 0.6.0 |
| 119 |
* |
| 120 |
* @param array $args Overwrite the default arguments used to fetch the items. |
| 121 |
* |
| 122 |
* @return bool|\WP_Error |
| 123 |
*/ |
| 124 |
public static function fetch( array $args = [] ): array; |
| 125 |
|
| 126 |
/** |
| 127 |
* Resets all the data on this module. |
| 128 |
* |
| 129 |
* @since 0.6.0 |
| 130 |
* |
| 131 |
* @return self |
| 132 |
*/ |
| 133 |
public function reset(): Interface_Module; |
| 134 |
|
| 135 |
/** |
| 136 |
* Use this method to generate all the needed data. |
| 137 |
* |
| 138 |
* @since 0.6.0 |
| 139 |
* @since 0.6.2 Added the $force parameter. |
| 140 |
* |
| 141 |
* @param bool $force Whether to force the regeneration of the data. |
| 142 |
* |
| 143 |
* @return self |
| 144 |
*/ |
| 145 |
public function generate( bool $force = false ): Interface_Module; |
| 146 |
|
| 147 |
/** |
| 148 |
* A method to make it easier to debug which variables will be actually saved. |
| 149 |
* |
| 150 |
* @param 0.6.0 |
| 151 |
* |
| 152 |
* @return array |
| 153 |
*/ |
| 154 |
public function get_values(): array; |
| 155 |
|
| 156 |
/** |
| 157 |
* A method to get the data for a given key. |
| 158 |
* |
| 159 |
* @param string $key |
| 160 |
* |
| 161 |
* @return array|null |
| 162 |
*/ |
| 163 |
public function get( string $key ): ?object; |
| 164 |
|
| 165 |
/** |
| 166 |
* A method to get the value for a given key. |
| 167 |
* |
| 168 |
* @param string $key |
| 169 |
* |
| 170 |
* @return mixed |
| 171 |
*/ |
| 172 |
public function get_value( string $key ); |
| 173 |
|
| 174 |
/** |
| 175 |
* Determines if a value is set for a given key. |
| 176 |
* |
| 177 |
* @param string $key |
| 178 |
* |
| 179 |
* @return bool |
| 180 |
*/ |
| 181 |
public function has_value( string $key ): bool; |
| 182 |
} |
| 183 |
|