icon_set = null; $this->config = clone $config; $this->config->access_mode_to_strict(); } /** * Generate set. */ public function generate_set() { $this->icon_set = array(); $rest_api = new P24_Rest_Heavy( $this->config ); $res = $rest_api->payment_methods( 'pl' ); if ( isset( $res['data'] ) ) { foreach ( $res['data'] as $row ) { $this->icon_set[ $row['id'] ] = array( 'base' => $row['imgUrl'], 'mobile' => $row['mobileImgUrl'], ); } } ksort( $this->icon_set, SORT_NUMERIC ); } /** * Get icon. * * @param int $id Id of payment method. * @param bool $mobile True for mobile version. * @return string|null */ public function get_icon( $id, $mobile ) { if ( ! isset( $this->icon_set ) ) { $this->generate_set(); } $id = (int) $id; if ( array_key_exists( $id, $this->icon_set ) ) { $type = $mobile ? 'mobile' : 'base'; return $this->icon_set[ $id ][ $type ]; } else { return null; } } /** * Get_all. * * @return array */ public function get_all() { if ( ! isset( $this->icon_set ) ) { $this->generate_set(); } return $this->icon_set; } }