PluginProbe
Timetics – Appointment Booking Calendar & Scheduling / trunk
Timetics – Appointment Booking Calendar & Scheduling vtrunk
1.0.61 1.0.60 1.0.59 1.0.58 1.0.57 1.0.56 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.2 1.0.20 1.0.21 1.0.22 1.0.23 1.0.24 All 62 releases
timetics / base / forward-calls.php

forward-calls.php in Timetics – Appointment Booking Calendar & Scheduling trunk, at base/forward-calls.php

53 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * ForwardCalls Trait
4 *
5 * @package Timetics
6 */
7 namespace Timetics\Base;
8
9 defined( 'ABSPATH' ) || exit;
10
11 use BadMethodCallException;
12 use Timetics\Base\PostModel;
13
14 /**
15 * ForwardCalls Trait
16 */
17 trait ForwardCalls {
18 /**
19 * Handle dynamic method
20 *
21 * @param PostModel $model
22 * @param string $method
23 * @param mixed $params
24 *
25 * @return mixed
26 */
27 protected static function forwardCallToStatic( PostModel $model, $method, $params ) {
28 try {
29 $post = new Post( $model );
30
31 return $post->$method( ...$params );
32
33 } catch ( BadMethodCallException $e ) {
34 static::throwBadMethodCallException( $method );
35 }
36 }
37
38 /**
39 * Throw a bad method call exception for the given method.
40 *
41 * @param string $method
42 * @return void
43 *
44 * @throws \BadMethodCallException
45 */
46 protected static function throwBadMethodCallException( $method ) {
47 throw new BadMethodCallException( sprintf(
48 /* translators: %1$s: Class name, %2$s: Method name */
49 esc_html__( 'Call to undefined method %1$s::%2$s()', 'timetics' ), static::class, esc_html( $method )
50 ) );
51 }
52 }
53