Factory.php
30 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WCML\PointerUi; |
| 4 | |
| 5 | use WPML\FP\Obj; |
| 6 | use WCML_Pointer_UI; |
| 7 | |
| 8 | class Factory { |
| 9 | |
| 10 | public static function create( $args ) { |
| 11 | $defaultArgs = [ |
| 12 | 'anchor' => __( 'How to translate this?', 'woocommerce-multilingual' ), |
| 13 | 'content' => '', |
| 14 | 'docLink' => null, |
| 15 | 'selectorId' => null, |
| 16 | 'method' => 'after', |
| 17 | ]; |
| 18 | $args = wp_parse_args( $args, $defaultArgs ); |
| 19 | |
| 20 | return new WCML_Pointer_UI( |
| 21 | Obj::prop( 'content', $args ), |
| 22 | Obj::prop( 'docLink', $args ), |
| 23 | Obj::prop( 'selectorId', $args ), |
| 24 | Obj::prop( 'method', $args ), |
| 25 | Obj::prop( 'anchor', $args ) |
| 26 | ); |
| 27 | } |
| 28 | |
| 29 | } |
| 30 |