PluginProbe
Elementor Website Builder – more than just a page builder / 3.30.3
Elementor Website Builder – more than just a page builder v3.30.3
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
elementor / core / utils / static-collection.php

static-collection.php in Elementor Website Builder – more than just a page builder 3.30.3, at core/utils/static-collection.php

52 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor\Core\Utils;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit; // Exit if accessed directly.
6 }
7
8 class Static_Collection {
9
10 /**
11 * The current Collection instance.
12 *
13 * @var Collection
14 */
15 protected $collection;
16
17 /**
18 * Return only unique values.
19 *
20 * @var bool
21 */
22 protected $unique_values = false;
23
24 /**
25 * @inheritDoc
26 */
27 public function __construct( array $items = [], $unique_values = false ) {
28 $this->collection = new Collection( $items );
29 $this->unique_values = $unique_values;
30 }
31
32 /**
33 * Since this class is a wrapper, every call will be forwarded to wrapped class.
34 * Most of the collection methods returns a new collection instance, and therefore
35 * it will be assigned as the current collection instance after executing any method.
36 *
37 * @param string $name
38 * @param array $arguments
39 */
40 public function __call( $name, $arguments ) {
41 $call = call_user_func_array( [ $this->collection, $name ], $arguments );
42
43 if ( $call instanceof Collection ) {
44 $this->collection = $this->unique_values ?
45 $call->unique() :
46 $call;
47 }
48
49 return $call;
50 }
51 }
52