diff --git a/composer.json b/composer.json index 270f6a3..6b945af 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "Utilities that make reading and writing PHP code more convenient and enjoyable", "type": "library", "license": "GPL-v2-or-later", - "version": "1.2.1", + "version": "1.2.2", "authors": [ { "name": "Elegant Themes", diff --git a/composer.lock b/composer.lock index 60d1b5a..b7351fc 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ad185d14a5d78dd6f8b5ef9a62d0734d", + "content-hash": "01004bdef83f5365d532d1e666d5fecd", "packages": [], "packages-dev": [], "aliases": [], @@ -16,5 +16,5 @@ "php": ">=7.4" }, "platform-dev": [], - "plugin-api-version": "1.1.0" + "plugin-api-version": "2.1.0" } diff --git a/src/Utils.php b/src/Utils.php index 4905fb2..417fc9f 100644 --- a/src/Utils.php +++ b/src/Utils.php @@ -129,6 +129,20 @@ public function _arraySortByCallback( $a, $b ): int { return 0; } + public function __call( $name, $args ) { + $class = __CLASS__; + + if ( method_exists( $this, $name ) ) { + throw new \Exception( "Call to protected or private method: {$class}::{$name}() from out of scope!" ); + } + + if ( method_exists( 'ET_Core_Data_Utils', $name ) ) { + return ET_Core_Data_Utils::instance()->$name( ...$args ); + } + + throw new \Exception( "Call to undefined method: {$class}::{$name}()" ); + } + /** * Returns `true` if all values in `$array` are not empty, `false` otherwise. * If `$callback` is provided then values are passed to it instead of {@see empty()} (it should return a booleon value).