INFRA-132 - Change "else if" to "elseif"
[civicrm-core.git] / CRM / Logging / Differ.php
index ac68cc6876d7a9c6e8e8e9836d1a93f96c1f821c..f75b638394b22ca4693fd76730109b0c5d0465eb 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
@@ -38,7 +38,12 @@ class CRM_Logging_Differ {
   private $log_date;
   private $interval;
 
-  function __construct($log_conn_id, $log_date, $interval = '10 SECOND') {
+  /**
+   * @param int $log_conn_id
+   * @param $log_date
+   * @param string $interval
+   */
+  public function __construct($log_conn_id, $log_date, $interval = '10 SECOND') {
     $dsn               = defined('CIVICRM_LOGGING_DSN') ? DB::parseDSN(CIVICRM_LOGGING_DSN) : DB::parseDSN(CIVICRM_DSN);
     $this->db          = $dsn['database'];
     $this->log_conn_id = $log_conn_id;
@@ -46,7 +51,12 @@ class CRM_Logging_Differ {
     $this->interval    = $interval;
   }
 
-  function diffsInTables($tables) {
+  /**
+   * @param $tables
+   *
+   * @return array
+   */
+  public function diffsInTables($tables) {
     $diffs = array();
     foreach ($tables as $table) {
       $diff = $this->diffsInTable($table);
@@ -57,7 +67,13 @@ class CRM_Logging_Differ {
     return $diffs;
   }
 
-  function diffsInTable($table, $contactID = null) {
+  /**
+   * @param $table
+   * @param int $contactID
+   *
+   * @return array
+   */
+  public function diffsInTable($table, $contactID = null) {
     $diffs = array();
 
     $params = array(
@@ -76,7 +92,7 @@ class CRM_Logging_Differ {
         $contactIdClause = "AND id = %3";
         break;
       case 'civicrm_note':
-        $contactIdClause = "AND ( entity_id = %3 AND entity_table = 'civicrm_contact' ) OR (entity_id IN (SELECT note.id FROM `{$this->db}`.log_civicrm_note note WHERE note.entity_id = %3 AND note.entity_table = 'civicrm_contact') AND entity_table = 'civicrm_note')";
+        $contactIdClause = "AND (( entity_id = %3 AND entity_table = 'civicrm_contact' ) OR (entity_id IN (SELECT note.id FROM `{$this->db}`.log_civicrm_note note WHERE note.entity_id = %3 AND note.entity_table = 'civicrm_contact') AND entity_table = 'civicrm_note'))";
         break;
       case 'civicrm_entity_tag':
         $contactIdClause = "AND entity_id = %3 AND entity_table = 'civicrm_contact'";
@@ -134,6 +150,12 @@ WHERE lt.log_conn_id = %1 AND
     return $diffs;
   }
 
+  /**
+   * @param $table
+   * @param int $id
+   *
+   * @return array
+   */
   private function diffsInTableForId($table, $id) {
     $diffs = array();
 
@@ -217,7 +239,12 @@ WHERE lt.log_conn_id = %1 AND
     return $diffs;
   }
 
-  function titlesAndValuesForTable($table) {
+  /**
+   * @param $table
+   *
+   * @return array
+   */
+  public function titlesAndValuesForTable($table) {
     // static caches for subsequent calls with the same $table
     static $titles = array();
     static $values = array();
@@ -286,7 +313,8 @@ WHERE lt.log_conn_id = %1 AND
       }
       elseif (substr($table, 0, 14) == 'civicrm_value_') {
         list($titles[$table], $values[$table]) = $this->titlesAndValuesForCustomDataTable($table);
-      } else {
+      }
+      else {
         $titles[$table] = $values[$table] = array();
       }
     }
@@ -294,12 +322,23 @@ WHERE lt.log_conn_id = %1 AND
     return array($titles[$table], $values[$table]);
   }
 
+  /**
+   * @param $sql
+   * @param array $params
+   *
+   * @return mixed
+   */
   private function sqlToArray($sql, $params) {
     $dao = CRM_Core_DAO::executeQuery($sql, $params);
     $dao->fetch();
     return $dao->toArray();
   }
 
+  /**
+   * @param $table
+   *
+   * @return array
+   */
   private function titlesAndValuesForCustomDataTable($table) {
     $titles = array();
     $values = array();
@@ -355,4 +394,3 @@ ORDER BY log_date
     return array($titles, $values);
   }
 }
-