| @@ 74-86 (lines=13) @@ | ||
| 71 | * |
|
| 72 | * @return array |
|
| 73 | */ |
|
| 74 | public static function filter(&$array, $callback) { |
|
| 75 | $result = array(); |
|
| 76 | ||
| 77 | if (is_array($array) && !empty($array)) { |
|
| 78 | foreach ($array as $value) { |
|
| 79 | if (call_user_func($callback, $value)) { |
|
| 80 | $result[] = $value; |
|
| 81 | } |
|
| 82 | } |
|
| 83 | } |
|
| 84 | ||
| 85 | return $result; |
|
| 86 | } |
|
| 87 | ||
| 88 | /** |
|
| 89 | * Filter empty() values from array |
|
| @@ 650-662 (lines=13) @@ | ||
| 647 | } |
|
| 648 | ||
| 649 | // TODO - redo as callable usage with array_map/array_walk |
|
| 650 | public function safeValues($values) { |
|
| 651 | $result = array(); |
|
| 652 | ||
| 653 | if (!is_array($values) || empty($values)) { |
|
| 654 | return $result; |
|
| 655 | } |
|
| 656 | ||
| 657 | foreach ($values as $key => $value) { |
|
| 658 | $result[$key] = $this->castAsDbValue($value); |
|
| 659 | } |
|
| 660 | ||
| 661 | return $result; |
|
| 662 | } |
|
| 663 | ||
| 664 | // TODO - redo as callable usage with array_map/array_walk |
|
| 665 | public function safeFields($fields) { |
|
| @@ 665-677 (lines=13) @@ | ||
| 662 | } |
|
| 663 | ||
| 664 | // TODO - redo as callable usage with array_map/array_walk |
|
| 665 | public function safeFields($fields) { |
|
| 666 | $result = array(); |
|
| 667 | ||
| 668 | if (!is_array($fields) || empty($fields)) { |
|
| 669 | return $result; |
|
| 670 | } |
|
| 671 | ||
| 672 | foreach ($fields as $key => $value) { |
|
| 673 | $result[$key] = "`" . $this->db_escape($value) . "`"; |
|
| 674 | } |
|
| 675 | ||
| 676 | return $result; |
|
| 677 | } |
|
| 678 | ||
| 679 | ||
| 680 | /** |
|