CRM-21264 - Minor refactoring
authorSean Madsen <sean@seanmadsen.com>
Thu, 15 Mar 2018 14:45:53 +0000 (10:45 -0400)
committerSean Madsen <sean@seanmadsen.com>
Thu, 15 Mar 2018 14:45:53 +0000 (10:45 -0400)
* Improve docblock
* Get rid of "dontCare" since that argument is optional as of PHP 5.4
  http://php.net/manual/en/function.preg-match-all.php#refsect1-function.preg-match-all-changelog
* Move regex to its own line to improve readability

CRM/Contribute/Form/Task/PDFLetterCommon.php

index 98cba059eda9ae7ae1ea7848e69dab3d0f4d6e7d..321ef460863d94d59cb2487513b456cab1ec509e 100644 (file)
@@ -188,17 +188,17 @@ class CRM_Contribute_Form_Task_PDFLetterCommon extends CRM_Contact_Form_Task_PDF
    * Check that the token only appears in a table cell. The '</td><td>' separator cannot otherwise work
    * Calculate the number of times it appears IN the cell & the number of times it appears - should be the same!
    *
-   * @param $token
-   * @param $entity
-   * @param $textToSearch
+   * @param string $token
+   * @param string $entity
+   * @param string $textToSearch
    *
    * @return bool
    */
   public static function isHtmlTokenInTableCell($token, $entity, $textToSearch) {
     $tokenToMatch = $entity . '.' . $token;
-    $dontCare = array();
-    $within = preg_match_all("|<td.+?{" . $tokenToMatch . "}.+?</td|si", $textToSearch, $dontCare);
-    $total = preg_match_all("|{" . $tokenToMatch . "}|", $textToSearch, $dontCare);
+    $pattern = '|<td.+?{' . $tokenToMatch . '}.+?</td|si';
+    $within = preg_match_all($pattern, $textToSearch);
+    $total = preg_match_all("|{" . $tokenToMatch . "}|", $textToSearch);
     return ($within == $total);
   }