Merge pull request #4809 from totten/master-cs2
[civicrm-core.git] / CRM / Financial / BAO / PaymentProcessor.php
index 4f8141528127800f277e3f0dc461bff320d94eab..3e0c66ab7608003c0f3a0cf5a7c5e0d8a761929d 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
 class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProcessor
 {
   /**
-   * static holder for the default payment processor
+   * Static holder for the default payment processor
    */
   static $_defaultPaymentProcessor = NULL;
 
-  /*
+  /**
    * Create Payment Processor
    *
-   * @params array parameters for Processor entity
-   */
-  /**
-   * @param $params
+   * @param array $params parameters for Processor entity
    *
    * @return CRM_Financial_DAO_PaymentProcessor
    * @throws Exception
    */
-  static function create($params) {
+  public static function create($params) {
     // FIXME Reconcile with CRM_Admin_Form_PaymentProcessor::updatePaymentProcessor
     $processor = new CRM_Financial_DAO_PaymentProcessor();
     $processor->copyValues($params);
@@ -88,9 +85,9 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces
   }
 
   /**
-   * class constructor
+   * Class constructor
    */
-  function __construct() {
+  public function __construct() {
     parent::__construct();
   }
 
@@ -102,11 +99,10 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces
    * @param array $params   (reference ) an assoc array of name/value pairs
    * @param array $defaults (reference ) an assoc array to hold the flattened values
    *
-     * @return object CRM_Financial_DAO_PaymentProcessor object on success, null otherwise
-   * @access public
+     * @return CRM_Financial_DAO_PaymentProcessor object on success, null otherwise
    * @static
    */
-  static function retrieve(&$params, &$defaults) {
+  public static function retrieve(&$params, &$defaults) {
     $paymentProcessor = new CRM_Financial_DAO_PaymentProcessor();
     $paymentProcessor->copyValues($params);
     if ($paymentProcessor->find(TRUE)) {
@@ -117,31 +113,29 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces
   }
 
   /**
-   * update the is_active flag in the db
+   * Update the is_active flag in the db
    *
    * @param int      $id        id of the database record
    * @param boolean  $is_active value we want to set the is_active field
    *
    * @return Object             DAO object on sucess, null otherwise
    *
-   * @access public
    * @static
    */
-  static function setIsActive($id, $is_active) {
+  public static function setIsActive($id, $is_active) {
     return CRM_Core_DAO::setFieldValue('CRM_Financial_DAO_PaymentProcessor', $id, 'is_active', $is_active);
   }
 
   /**
-   * retrieve the default payment processor
+   * Retrieve the default payment processor
    *
    * @param NULL
    *
    * @return object           The default payment processor object on success,
    *                          null otherwise
    * @static
-   * @access public
    */
-  static function &getDefault() {
+  public static function &getDefault() {
     if (self::$_defaultPaymentProcessor == NULL) {
       $params = array('is_default' => 1);
       $defaults = array();
@@ -153,17 +147,14 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces
   /**
    * Function  to delete payment processor
    *
-   * @param $paymentProcessorID
+   * @param int $paymentProcessorID
    *
    * @return null
-   * @internal param int $paymentProcessorId ID of the processor to be deleted.
-   *
-   * @access public
    * @static
    */
-  static function del($paymentProcessorID) {
+  public static function del($paymentProcessorID) {
     if (!$paymentProcessorID) {
-      CRM_Core_Error::fatal(ts('Invalid value passed to delete function'));
+      CRM_Core_Error::fatal(ts('Invalid value passed to delete function.'));
     }
 
     $dao = new CRM_Financial_DAO_PaymentProcessor();
@@ -181,16 +172,15 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces
   }
 
   /**
-   * Function to get the payment processor details
+   * Get the payment processor details
    *
    * @param  int    $paymentProcessorID payment processor id
    * @param  string $mode               payment mode ie test or live
    *
    * @return array  associated array with payment processor related fields
    * @static
-   * @access public
    */
-  static function getPayment($paymentProcessorID, $mode) {
+  public static function getPayment($paymentProcessorID, $mode) {
     if (!$paymentProcessorID) {
       CRM_Core_Error::fatal(ts('Invalid value passed to getPayment function'));
     }
@@ -224,7 +214,7 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces
    * @return array
    * @throws Exception
    */
-  static function getPayments($paymentProcessorIDs, $mode) {
+  public static function getPayments($paymentProcessorIDs, $mode) {
     if (!$paymentProcessorIDs) {
       CRM_Core_Error::fatal(ts('Invalid value passed to getPayment function'));
     }
@@ -240,13 +230,13 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces
   }
 
   /**
-   * compare 2 payment processors to see which should go first based on is_default
+   * Compare 2 payment processors to see which should go first based on is_default
    * (sort function for sortDefaultFirst)
    * @param array $processor1
    * @param array_type $processor2
    * @return number
    */
-    static function defaultComparison($processor1, $processor2){
+    public static function defaultComparison($processor1, $processor2){
       $p1 = CRM_Utils_Array::value('is_default', $processor1);
       $p2 = CRM_Utils_Array::value('is_default', $processor2);
       if ($p1 == $p2) {
@@ -256,16 +246,15 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces
     }
 
   /**
-   * Function to build payment processor details
+   * Build payment processor details
    *
    * @param object $dao   payment processor object
    * @param  string $mode payment mode ie test or live
    *
    * @return array  associated array with payment processor related fields
    * @static
-   * @access public
    */
-  static function buildPayment($dao, $mode) {
+  public static function buildPayment($dao, $mode) {
     $fields = array(
       'id', 'name', 'payment_processor_type_id', 'user_name', 'password',
       'signature', 'url_site', 'url_api', 'url_recur', 'url_button',
@@ -284,7 +273,7 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces
   }
 
   /**
-   * get all payment processors as an array of objects.
+   * Get all payment processors as an array of objects.
    *
    * @param $isExcludeTest
    * @param bool $reset
@@ -292,7 +281,7 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces
    * @throws CiviCRM_API3_Exception
    * @return array
    */
-  static function getAllPaymentProcessors($isExcludeTest, $reset = FALSE) {
+  public static function getAllPaymentProcessors($isExcludeTest, $reset = FALSE) {
     /**
      * $cacheKey = 'CRM_Financial_BAO_Payment_Processor_' . ($isExcludeTest ? 'test' : 'all');
     if (!$reset) {
@@ -318,7 +307,7 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces
   }
 
   /**
-   * get Payment processors with specified capabilities.
+   * Get Payment processors with specified capabilities.
    * Note that both the singleton & the pseudoconstant function have caching so we don't add
    * arguably this could go on the pseudoconstant class
    *
@@ -329,7 +318,7 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces
    *
    * @return array available processors
    */
-  static function getPaymentProcessors($capabilities = array(), $isIncludeTest = FALSE, $ids = array()) {
+  public static function getPaymentProcessors($capabilities = array(), $isIncludeTest = FALSE, $ids = array()) {
     $processors = self::getAllPaymentProcessors(!$isIncludeTest);
     if ($capabilities) {
       foreach ($processors as $index => $processor) {
@@ -358,24 +347,22 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces
    *
    * @return bool
    */
-  static function hasPaymentProcessorSupporting($capabilities = array(), $isIncludeTest = FALSE) {
+  public static function hasPaymentProcessorSupporting($capabilities = array(), $isIncludeTest = FALSE) {
     $result = self::getPaymentProcessors($capabilities, $isIncludeTest);
     return (!empty($result)) ? TRUE : FALSE;
   }
 
   /**
-   * Function to retrieve payment processor id / info/ object based on component-id.
+   * Retrieve payment processor id / info/ object based on component-id.
    *
-   * @param $entityID
+   * @param int $entityID
    * @param string $component component
    * @param string $type type of payment information to be retrieved
    *
-   * @internal param int $componentID id of a component
-   * @return id / array / object based on type
+   * @return int / array / object based on type
    * @static
-   * @access public
    */
-  static function getProcessorForEntity($entityID, $component = 'contribute', $type = 'id') {
+  public static function getProcessorForEntity($entityID, $component = 'contribute', $type = 'id') {
     $result = NULL;
     if (!in_array($component, array(
       'membership', 'contribute', 'recur'))) {
@@ -435,4 +422,3 @@ INNER JOIN civicrm_contribution       con ON ( mp.contribution_id = con.id )
     return $result;
   }
 }
-