PluginProbe
Timetics – Appointment Booking Calendar & Scheduling / 1.0.56
Timetics – Appointment Booking Calendar & Scheduling v1.0.56
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 1.0.56, at base/forward-calls.php

51 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 use BadMethodCallException;
10 use Timetics\Base\PostModel;
11
12 /**
13 * ForwardCalls Trait
14 */
15 trait ForwardCalls {
16 /**
17 * Handle dynamic method
18 *
19 * @param PostModel $model
20 * @param string $method
21 * @param mixed $params
22 *
23 * @return mixed
24 */
25 protected static function forwardCallToStatic( PostModel $model, $method, $params ) {
26 try {
27 $post = new Post( $model );
28
29 return $post->$method( ...$params );
30
31 } catch ( BadMethodCallException $e ) {
32 static::throwBadMethodCallException( $method );
33 }
34 }
35
36 /**
37 * Throw a bad method call exception for the given method.
38 *
39 * @param string $method
40 * @return void
41 *
42 * @throws \BadMethodCallException
43 */
44 protected static function throwBadMethodCallException( $method ) {
45 throw new BadMethodCallException( sprintf(
46 /* translators: %1$s: Class name, %2$s: Method name */
47 esc_html__( 'Call to undefined method %1$s::%2$s()', 'timetics' ), static::class, esc_html( $method )
48 ) );
49 }
50 }
51