ArrayColumn.php
1 year ago
ArrayFlatten.php
1 year ago
ArrayKeys.php
1 year ago
ArraySearch.php
1 year ago
ArrayValues.php
1 year ago
Count.php
1 year ago
DotNotation.php
1 year ago
PrepareUrl.php
1 year ago
TransformerInterface.php
1 year ago
TransformerService.php
1 year ago
ArrayKeys.php
42 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors\Transformers; |
| 4 | |
| 5 | use Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors\Transformers\TransformerInterface; |
| 6 | use stdClass; |
| 7 | |
| 8 | /** |
| 9 | * Search array value by one of its key. |
| 10 | * |
| 11 | * @package Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors\Transformers |
| 12 | */ |
| 13 | class ArrayKeys implements TransformerInterface { |
| 14 | /** |
| 15 | * Search array value by one of its key. |
| 16 | * |
| 17 | * @param mixed $value a value to transform. |
| 18 | * @param stdClass|null $arguments arguments. |
| 19 | * @param string|null $default_value default value. |
| 20 | * |
| 21 | * @return mixed |
| 22 | */ |
| 23 | public function transform( $value, ?stdClass $arguments = null, $default_value = array() ) { |
| 24 | if ( ! is_array( $value ) ) { |
| 25 | return $default_value; |
| 26 | } |
| 27 | |
| 28 | return array_keys( $value ); |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * Validate Transformer arguments. |
| 33 | * |
| 34 | * @param stdClass|null $arguments arguments to validate. |
| 35 | * |
| 36 | * @return mixed |
| 37 | */ |
| 38 | public function validate( ?stdClass $arguments = null ) { |
| 39 | return true; |
| 40 | } |
| 41 | } |
| 42 |