PluginProbe
PostNL for WooCommerce / 4.0.0
PostNL for WooCommerce v4.0.0
5.9.12 5.9.11 5.9.10 5.9.9 5.9.8 5.9.7 5.9.6 trunk 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 3.1.4 3.1.5 3.1.6 3.1.7 4.0.0 4.0.1 4.0.2 4.3.2 4.3.3 4.4.0 4.4.1 All 72 releases
woo-postnl / includes / vendor / myparcelnl / sdk / src / Support / HigherOrderWhenProxy.php

HigherOrderWhenProxy.php in PostNL for WooCommerce 4.0.0, at includes/vendor/myparcelnl/sdk/src/Support/HigherOrderWhenProxy.php

60 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php declare(strict_types=1);
2
3 namespace MyParcelNL\Sdk\src\Support;
4
5 /**
6 * @mixin Collection
7 */
8 class HigherOrderWhenProxy
9 {
10 /**
11 * The collection being operated on.
12 *
13 * @var Collection
14 */
15 protected $collection;
16
17 /**
18 * The condition for proxying.
19 *
20 * @var bool
21 */
22 protected $condition;
23
24 /**
25 * Create a new proxy instance.
26 *
27 * @param Collection $collection
28 * @param bool $condition
29 * @return void
30 */
31 public function __construct(Collection $collection, $condition)
32 {
33 $this->condition = $condition;
34 $this->collection = $collection;
35 }
36
37 /**
38 * Proxy accessing an attribute onto the collection.
39 *
40 * @param string $key
41 * @return mixed
42 */
43 public function __get($key)
44 {
45 return $this->condition ? $this->collection->{$key} : $this->collection;
46 }
47
48 /**
49 * Proxy a method call onto the collection.
50 *
51 * @param string $method
52 * @param array $parameters
53 * @return mixed
54 */
55 public function __call($method, $parameters)
56 {
57 return $this->condition ? $this->collection->{$method}(...$parameters) : $this->collection;
58 }
59 }
60