PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.0.4
JetFormBuilder — Dynamic Blocks Form Builder v3.0.4
3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / includes / classes / arrayable / array-tools.php
jetformbuilder / includes / classes / arrayable Last commit date
array-continue-exception.php 3 years ago array-convert-once.php 3 years ago array-tools.php 3 years ago arrayable-once.php 3 years ago arrayable.php 3 years ago collection-item-interface.php 3 years ago collection.php 3 years ago
array-tools.php
67 lines
1 <?php
2
3
4 namespace Jet_Form_Builder\Classes\Arrayable;
5
6 use Jet_Form_Builder\Actions\Methods\Post_Modification\Post_Je_Relation_Property;
7
8 class Array_Tools {
9
10 /**
11 * @param array|\Generator $payload
12 *
13 * @return array
14 */
15 public static function to_array( $payload ): array {
16 if ( $payload instanceof \Generator ) {
17 return self::from_generator( $payload );
18 }
19
20 return self::from_array( $payload );
21 }
22
23 public static function from_generator( \Generator $generator ): array {
24 $response = array();
25
26 foreach ( $generator as $value ) {
27 $response[] = $value;
28 }
29
30 return $response;
31 }
32
33 /**
34 * @param array|Collection $iterator
35 *
36 * @return \Generator
37 */
38 public static function reverse( $iterator ): \Generator {
39 for ( $current = count( $iterator ) - 1; $current >= 0; $current -- ) {
40 yield $iterator[ $current ];
41 }
42 }
43
44 public static function from_array( array $payload ): array {
45 foreach ( $payload as $index => $object ) {
46 if ( is_array( $object ) ) {
47 continue;
48 }
49
50 /** @var Arrayable $object */
51 if ( is_object( $object ) && ! ( $object instanceof Arrayable ) ) {
52 wp_die( 'Must implements Arrayable.', 'Illegal item of array' );
53 }
54
55 try {
56 $payload[ $index ] = $object->to_array();
57 } catch ( Array_Continue_Exception $exception ) {
58 unset( $payload[ $index ] );
59 continue;
60 }
61 }
62
63 return array_values( $payload );
64 }
65
66 }
67