| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * Copyright (c) 2013-2014 eBay Enterprise, Inc. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * NOTICE OF LICENSE | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * This source file is subject to the Open Software License (OSL 3.0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * that is bundled with this package in the file LICENSE.md. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * It is also available through the world-wide-web at this URL: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * http://opensource.org/licenses/osl-3.0.php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * @copyright   Copyright (c) 2013-2014 eBay Enterprise, Inc. (http://www.ebayenterprise.com/) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | class EbayEnterprise_GiftCard_Helper_Data extends Mage_Core_Helper_Abstract implements EbayEnterprise_Eb2cCore_Helper_Interface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     const ZERO_BALANCE_CARD_MESSAGE = 'EbayEnterprise_GiftCard_Zero_Balance_Card'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |      * Type checks for self::__construct $initParams | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |      * @param  EbayEnterprise_GiftCard_Model_IContainer $checkoutSession | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |      * @param  EbayEnterprise_MageLog_Helper_Data $logger | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |      * @return mixed[] | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     protected function _checkTypes( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |         EbayEnterprise_GiftCard_Model_IContainer $container | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |         return array($container); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |      * Return the value at field in array if it exists. Otherwise, use the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |      * default value. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |      * @param  array      $arr | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |      * @param  string|int $field Valid array key | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |      * @param  mixed      $default | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |      * @return mixed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     protected function _nullCoalesce(array $arr, $field, $default) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         return isset($arr[$field]) ? $arr[$field] : $default; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |      * @see EbayEnterprise_Eb2cCore_Helper_Interface::getConfigModel | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |      * @param mixed $store | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |      * @return EbayEnterprise_Eb2cCore_Model_Config_Registry | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     public function getConfigModel($store = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |         return Mage::getModel('eb2ccore/config_registry') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |             ->setStore($store) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |             ->addConfigModel(Mage::getSingleton('ebayenterprise_giftcard/config')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |      * Add a gift card to the container. Will make the gift card balance check | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |      * and make sure card can be applied to the order. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |      * @param EbayEnterprise_GiftCard_Model_IGiftcard $card | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |      * @return self | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |      * @throws EbayEnterprise_GiftCard_Exception If gift card could not be added to the order. | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 63 |  |  |      */ | 
            
                                                        
            
                                    
            
            
                | 64 |  |  |     public function addGiftCardToOrder( | 
            
                                                        
            
                                    
            
            
                | 65 |  |  |         EbayEnterprise_GiftCard_Model_IGiftcard $card, | 
            
                                                        
            
                                    
            
            
                | 66 |  |  |         EbayEnterprise_GiftCard_Model_IContainer $giftCardContainer | 
            
                                                        
            
                                    
            
            
                | 67 |  |  |     ) { | 
            
                                                        
            
                                    
            
            
                | 68 |  |  |         $card->checkBalance(); | 
            
                                                        
            
                                    
            
            
                | 69 |  |  |         // only add cards with an available balance | 
            
                                                        
            
                                    
            
            
                | 70 |  |  |         if ($card->getBalanceAmount() > 0) { | 
            
                                                        
            
                                    
            
            
                | 71 |  |  |             $giftCardContainer->updateGiftCard($card); | 
            
                                                        
            
                                    
            
            
                | 72 |  |  |         } else { | 
            
                                                        
            
                                    
            
            
                | 73 |  |  |             // throw exception to trigger error handling below, let 0 balance card | 
            
                                                        
            
                                    
            
            
                | 74 |  |  |             // get handled like any other balance check failure | 
            
                                                        
            
                                    
            
            
                | 75 |  |  |             throw Mage::exception('EbayEnterprise_GiftCard', $this->__(self::ZERO_BALANCE_CARD_MESSAGE, $card->getCardNumber())); | 
            
                                                        
            
                                    
            
            
                | 76 |  |  |         } | 
            
                                                        
            
                                    
            
            
                | 77 |  |  |         return $this; | 
            
                                                        
            
                                    
            
            
                | 78 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 79 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 80 |  |  |  | 
            
                        
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.