model-helper.php (1738B)
1 <?php 2 namespace Elementor\Modules\System_Info\Helpers; 3 4 if ( ! defined( 'ABSPATH' ) ) { 5 exit; // Exit if accessed directly. 6 } 7 8 /** 9 * Elementor model helper. 10 * 11 * Elementor model helper handler class is responsible for filtering properties. 12 * 13 * @since 1.0.0 14 */ 15 final class Model_Helper { 16 17 /** 18 * Model helper constructor. 19 * 20 * Initializing the model helper class. 21 * 22 * @since 1.0.0 23 * @access private 24 */ 25 private function __construct() {} 26 27 /** 28 * Filter possible properties. 29 * 30 * Retrieve possible properties filtered by property intersect key. 31 * 32 * @since 1.0.0 33 * @access public 34 * @static 35 * 36 * @param array $possible_properties All the possible properties. 37 * @param array $properties Properties to filter. 38 * 39 * @return array Possible properties filtered by property intersect key. 40 */ 41 public static function filter_possible_properties( $possible_properties, $properties ) { 42 $properties_keys = array_flip( $possible_properties ); 43 44 return array_intersect_key( $properties, $properties_keys ); 45 } 46 47 /** 48 * Prepare properties. 49 * 50 * Combine the possible properties with the user properties and filter them. 51 * 52 * @since 1.0.0 53 * @access public 54 * @static 55 * 56 * @param array $possible_properties All the possible properties. 57 * @param array $user_properties User properties. 58 * 59 * @return array Possible properties and user properties filtered by property intersect key. 60 */ 61 public static function prepare_properties( $possible_properties, $user_properties ) { 62 $properties = array_fill_keys( $possible_properties, null ); 63 64 $properties = array_merge( $properties, $user_properties ); 65 66 return self::filter_possible_properties( $possible_properties, $properties ); 67 } 68 }