Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like Arrayy often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Arrayy, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 14 | class Arrayy extends ArrayyAbstract implements \Countable, \IteratorAggregate, \ArrayAccess |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * Initializes |
||
| 18 | * |
||
| 19 | * @param array $array |
||
| 20 | */ |
||
| 21 | 403 | public function __construct($array = array()) |
|
| 43 | |||
| 44 | /** |
||
| 45 | * magic to string |
||
| 46 | * |
||
| 47 | * @return string |
||
| 48 | */ |
||
| 49 | 14 | public function __toString() |
|
| 53 | |||
| 54 | /** |
||
| 55 | * Get a data by key |
||
| 56 | * |
||
| 57 | * @param $key |
||
| 58 | * |
||
| 59 | * @return mixed |
||
| 60 | */ |
||
| 61 | public function &__get($key) |
||
| 65 | |||
| 66 | /** |
||
| 67 | * Assigns a value to the specified data |
||
| 68 | * |
||
| 69 | * @param $key |
||
| 70 | * @param $value |
||
| 71 | */ |
||
| 72 | public function __set($key, $value) |
||
| 76 | |||
| 77 | /** |
||
| 78 | * Whether or not an data exists by key |
||
| 79 | * |
||
| 80 | * @param $key |
||
| 81 | * |
||
| 82 | * @return bool |
||
| 83 | */ |
||
| 84 | public function __isset($key) |
||
| 88 | |||
| 89 | /** |
||
| 90 | * Unsets an data by key |
||
| 91 | * |
||
| 92 | * @param mixed $key |
||
| 93 | */ |
||
| 94 | public function __unset($key) |
||
| 98 | |||
| 99 | /** |
||
| 100 | * Assigns a value to the specified offset |
||
| 101 | * |
||
| 102 | * |
||
| 103 | * @param mixed $offset |
||
| 104 | * @param mixed $value |
||
| 105 | */ |
||
| 106 | 2 | public function offsetSet($offset, $value) |
|
| 107 | { |
||
| 108 | 2 | if (null === $offset) { |
|
| 109 | $this->array[] = $value; |
||
| 110 | } else { |
||
| 111 | 2 | $this->array[$offset] = $value; |
|
| 112 | } |
||
| 113 | 2 | } |
|
| 114 | |||
| 115 | /** |
||
| 116 | * Whether or not an offset exists |
||
| 117 | * |
||
| 118 | * @param mixed $offset |
||
| 119 | * |
||
| 120 | * @return bool |
||
| 121 | */ |
||
| 122 | 9 | public function offsetExists($offset) |
|
| 126 | |||
| 127 | /** |
||
| 128 | * Unsets an offset |
||
| 129 | * |
||
| 130 | * @param mixed $offset |
||
| 131 | */ |
||
| 132 | 1 | public function offsetUnset($offset) |
|
| 133 | { |
||
| 134 | 1 | if ($this->offsetExists($offset)) { |
|
| 135 | 1 | unset($this->array[$offset]); |
|
| 136 | 1 | } |
|
| 137 | 1 | } |
|
| 138 | |||
| 139 | /** |
||
| 140 | * Returns the value at specified offset |
||
| 141 | * |
||
| 142 | * @param mixed $offset |
||
| 143 | * |
||
| 144 | * @return null |
||
| 145 | */ |
||
| 146 | 8 | public function offsetGet($offset) |
|
| 150 | |||
| 151 | /** |
||
| 152 | * Returns a new ArrayIterator, thus implementing the IteratorAggregate |
||
| 153 | * interface. |
||
| 154 | * |
||
| 155 | * @return \ArrayIterator An iterator for the values in the array |
||
| 156 | */ |
||
| 157 | 2 | public function getIterator() |
|
| 161 | |||
| 162 | /** |
||
| 163 | * call object as function |
||
| 164 | * |
||
| 165 | * @param mixed $key |
||
| 166 | * |
||
| 167 | * @return mixed |
||
| 168 | */ |
||
| 169 | public function __invoke($key = null) |
||
| 181 | |||
| 182 | /** |
||
| 183 | * get the current array from the "Arrayy"-object |
||
| 184 | * |
||
| 185 | * @return array |
||
| 186 | */ |
||
| 187 | 231 | public function getArray() |
|
| 191 | |||
| 192 | /** |
||
| 193 | * Creates a Arrayy object |
||
| 194 | * |
||
| 195 | * @param array $array |
||
| 196 | * |
||
| 197 | * @return Arrayy |
||
| 198 | */ |
||
| 199 | 306 | public static function create($array = array()) |
|
| 203 | |||
| 204 | /** |
||
| 205 | * Create a new Arrayy object via string. |
||
| 206 | * |
||
| 207 | * @param string $str The input string. |
||
| 208 | * @param string|null $delimiter The boundary string. |
||
| 209 | * @param string|null $regEx Use the $delimiter or the $regEx, so if $pattern is null, $delimiter will be used. |
||
| 210 | * |
||
| 211 | * @return Arrayy |
||
| 212 | */ |
||
| 213 | 2 | public static function createFromString($str, $delimiter, $regEx = null) |
|
| 238 | |||
| 239 | /** |
||
| 240 | * create a new Arrayy object via JSON, |
||
| 241 | * |
||
| 242 | * @param string $json |
||
| 243 | * |
||
| 244 | * @return Arrayy |
||
| 245 | */ |
||
| 246 | 1 | public static function createFromJson($json) |
|
| 252 | |||
| 253 | //////////////////////////////////////////////////////////////////// |
||
| 254 | ///////////////////////////// ANALYZE ////////////////////////////// |
||
| 255 | //////////////////////////////////////////////////////////////////// |
||
| 256 | |||
| 257 | /** |
||
| 258 | * Search for the value of the current array via $index. |
||
| 259 | * |
||
| 260 | * @param mixed $index |
||
| 261 | * |
||
| 262 | * @return Arrayy will return a empty Arrayy if the value wasn't found |
||
| 263 | */ |
||
| 264 | 7 | public function searchValue($index) |
|
| 279 | |||
| 280 | /** |
||
| 281 | * Search for the first index of the current array via $value. |
||
| 282 | * |
||
| 283 | * @param mixed $value |
||
| 284 | * |
||
| 285 | * @return Arrayy will return a empty Arrayy if the index wasn't found |
||
| 286 | */ |
||
| 287 | 16 | public function searchIndex($value) |
|
| 299 | |||
| 300 | /** |
||
| 301 | * Check if all items in current array match a truth test. |
||
| 302 | * |
||
| 303 | * @param \Closure $closure |
||
| 304 | * |
||
| 305 | * @return bool |
||
| 306 | */ |
||
| 307 | 9 | View Code Duplication | public function matches(\Closure $closure) |
| 320 | |||
| 321 | /** |
||
| 322 | * Check if any item in the current array matches a truth test. |
||
| 323 | * |
||
| 324 | * @param \Closure $closure |
||
| 325 | * |
||
| 326 | * @return bool |
||
| 327 | */ |
||
| 328 | 9 | View Code Duplication | public function matchesAny(\Closure $closure) |
| 341 | |||
| 342 | /** |
||
| 343 | * Check if we have named keys in the current array. |
||
| 344 | * |
||
| 345 | * @return bool |
||
| 346 | */ |
||
| 347 | 12 | public function isAssoc() |
|
| 355 | |||
| 356 | /** |
||
| 357 | * Check if the current array is a multi-array. |
||
| 358 | * |
||
| 359 | * @return bool |
||
| 360 | */ |
||
| 361 | 13 | public function isMultiArray() |
|
| 365 | |||
| 366 | /** |
||
| 367 | * Check if an item is in the current array. |
||
| 368 | * |
||
| 369 | * @param mixed $value |
||
| 370 | * |
||
| 371 | * @return bool |
||
| 372 | */ |
||
| 373 | 9 | public function contains($value) |
|
| 377 | |||
| 378 | /** |
||
| 379 | * Returns the average value of the current array. |
||
| 380 | * |
||
| 381 | * @param int $decimals The number of decimals to return |
||
| 382 | * |
||
| 383 | * @return int|double The average value |
||
| 384 | */ |
||
| 385 | 10 | public function average($decimals = null) |
|
| 399 | |||
| 400 | /** |
||
| 401 | * Count the values from the current array. |
||
| 402 | * |
||
| 403 | * INFO: only a alias for "$arrayy->size()" |
||
| 404 | * |
||
| 405 | * @return int |
||
| 406 | */ |
||
| 407 | 10 | public function length() |
|
| 411 | |||
| 412 | /** |
||
| 413 | * Count the values from the current array. |
||
| 414 | * |
||
| 415 | * INFO: only a alias for "$arrayy->size()" |
||
| 416 | * |
||
| 417 | * @return int |
||
| 418 | */ |
||
| 419 | 59 | public function count() |
|
| 423 | |||
| 424 | /** |
||
| 425 | * Get the size of an array. |
||
| 426 | * |
||
| 427 | * @return int |
||
| 428 | */ |
||
| 429 | 59 | public function size() |
|
| 433 | |||
| 434 | /** |
||
| 435 | * Get the max value from an array. |
||
| 436 | * |
||
| 437 | * @return mixed |
||
| 438 | */ |
||
| 439 | 10 | public function max() |
|
| 447 | |||
| 448 | /** |
||
| 449 | * Get the min value from an array. |
||
| 450 | * |
||
| 451 | * @return mixed |
||
| 452 | */ |
||
| 453 | 10 | public function min() |
|
| 461 | |||
| 462 | //////////////////////////////////////////////////////////////////// |
||
| 463 | //////////////////////////// FETCH FROM //////////////////////////// |
||
| 464 | //////////////////////////////////////////////////////////////////// |
||
| 465 | |||
| 466 | /** |
||
| 467 | * Find the first item in an array that passes the truth test, |
||
| 468 | * otherwise return false |
||
| 469 | * |
||
| 470 | * @param \Closure $closure |
||
| 471 | * |
||
| 472 | * @return mixed|false false if we couldn't find the value |
||
| 473 | */ |
||
| 474 | 7 | public function find(\Closure $closure) |
|
| 484 | |||
| 485 | /** |
||
| 486 | * Clean all falsy values from an array. |
||
| 487 | * |
||
| 488 | * @return Arrayy |
||
| 489 | */ |
||
| 490 | 8 | public function clean() |
|
| 498 | |||
| 499 | /** |
||
| 500 | * Get a random string from an array. |
||
| 501 | * |
||
| 502 | * @param null|int $take how many values you will take? |
||
| 503 | * |
||
| 504 | * @return Arrayy |
||
| 505 | */ |
||
| 506 | 18 | public function random($take = null) |
|
| 520 | |||
| 521 | /** |
||
| 522 | * Get a random value from an array, with the ability to skew the results. |
||
| 523 | * |
||
| 524 | * Example: randomWeighted(['foo' => 1, 'bar' => 2]) has a 66% chance of returning bar. |
||
| 525 | * |
||
| 526 | * @param array $array |
||
| 527 | * @param null|int $take how many values you will take? |
||
| 528 | * |
||
| 529 | * @return Arrayy |
||
| 530 | */ |
||
| 531 | 9 | public function randomWeighted(array $array, $take = null) |
|
| 544 | |||
| 545 | /** |
||
| 546 | * Return an array with all elements found in input array. |
||
| 547 | * |
||
| 548 | * @param array $search |
||
| 549 | * |
||
| 550 | * @return Arrayy |
||
| 551 | */ |
||
| 552 | 2 | public function intersection(array $search) |
|
| 556 | |||
| 557 | /** |
||
| 558 | * Return a boolean flag which indicates whether the two input arrays have any common elements. |
||
| 559 | * |
||
| 560 | * @param array $search |
||
| 561 | * |
||
| 562 | * @return bool |
||
| 563 | */ |
||
| 564 | 1 | public function intersects(array $search) |
|
| 568 | |||
| 569 | //////////////////////////////////////////////////////////////////// |
||
| 570 | ///////////////////////////// SLICERS ////////////////////////////// |
||
| 571 | //////////////////////////////////////////////////////////////////// |
||
| 572 | |||
| 573 | /** |
||
| 574 | * Get the first value(s) from the current array. |
||
| 575 | * |
||
| 576 | * @param int|null $take how many values you will take? |
||
| 577 | * |
||
| 578 | * @return Arrayy |
||
| 579 | */ |
||
| 580 | 33 | public function first($take = null) |
|
| 590 | |||
| 591 | /** |
||
| 592 | * Get the last value(s) from the current array. |
||
| 593 | * |
||
| 594 | * @param int|null $take |
||
| 595 | * |
||
| 596 | * @return Arrayy |
||
| 597 | */ |
||
| 598 | 11 | public function last($take = null) |
|
| 608 | |||
| 609 | /** |
||
| 610 | * Get everything but the last..$to items. |
||
| 611 | * |
||
| 612 | * @param int $to |
||
| 613 | * |
||
| 614 | * @return Arrayy |
||
| 615 | */ |
||
| 616 | 12 | public function initial($to = 1) |
|
| 622 | |||
| 623 | /** |
||
| 624 | * Get the last elements from index $from until the end of this array. |
||
| 625 | * |
||
| 626 | * @param int $from |
||
| 627 | * |
||
| 628 | * @return Arrayy |
||
| 629 | */ |
||
| 630 | 16 | public function rest($from = 1) |
|
| 634 | |||
| 635 | //////////////////////////////////////////////////////////////////// |
||
| 636 | ///////////////////////////// ACT UPON ///////////////////////////// |
||
| 637 | //////////////////////////////////////////////////////////////////// |
||
| 638 | |||
| 639 | /** |
||
| 640 | * Iterate over an array and execute a callback for each loop. |
||
| 641 | * |
||
| 642 | * @param \Closure $closure |
||
| 643 | * |
||
| 644 | * @return Arrayy |
||
| 645 | */ |
||
| 646 | 2 | View Code Duplication | public function at(\Closure $closure) |
| 656 | |||
| 657 | //////////////////////////////////////////////////////////////////// |
||
| 658 | ////////////////////////////// ALTER /////////////////////////////// |
||
| 659 | //////////////////////////////////////////////////////////////////// |
||
| 660 | |||
| 661 | /** |
||
| 662 | * Merge the new $array into the current array. |
||
| 663 | * |
||
| 664 | * - replace duplicate assoc-keys from the current array with the key,values from the new $array |
||
| 665 | * - create new indexes |
||
| 666 | * |
||
| 667 | * @param array $array |
||
| 668 | * |
||
| 669 | * @return Arrayy |
||
| 670 | */ |
||
| 671 | 8 | public function mergeAppendNewIndex(array $array = array()) |
|
| 675 | |||
| 676 | /** |
||
| 677 | * Merge the current array into the new $array. |
||
| 678 | * |
||
| 679 | * - replace duplicate assoc-keys from new $array with the key,values from the current array |
||
| 680 | * - create new indexes |
||
| 681 | * |
||
| 682 | * @param array $array |
||
| 683 | * |
||
| 684 | * @return Arrayy |
||
| 685 | */ |
||
| 686 | 8 | public function mergePrependNewIndex(array $array = array()) |
|
| 690 | |||
| 691 | /** |
||
| 692 | * Merge the new $array into the current array. |
||
| 693 | * |
||
| 694 | * - keep key,value from the current array, also if the index is in the new $array |
||
| 695 | * |
||
| 696 | * @param array $array |
||
| 697 | * |
||
| 698 | * @return Arrayy |
||
| 699 | */ |
||
| 700 | 17 | public function mergeAppendKeepIndex(array $array = array()) |
|
| 704 | |||
| 705 | /** |
||
| 706 | * Merge the the current array into the $array. |
||
| 707 | * |
||
| 708 | * - use key,value from the new $array, also if the index is in the current array |
||
| 709 | * |
||
| 710 | * @param array $array |
||
| 711 | * |
||
| 712 | * @return Arrayy |
||
| 713 | */ |
||
| 714 | 8 | public function mergePrependKeepIndex(array $array = array()) |
|
| 718 | |||
| 719 | /** |
||
| 720 | * Return values that are only in the current array. |
||
| 721 | * |
||
| 722 | * @param array $array |
||
| 723 | * |
||
| 724 | * @return Arrayy |
||
| 725 | */ |
||
| 726 | 8 | public function diff(array $array = array()) |
|
| 730 | |||
| 731 | /** |
||
| 732 | * Return values that are only in the new $array. |
||
| 733 | * |
||
| 734 | * @param array $array |
||
| 735 | * |
||
| 736 | * @return Arrayy |
||
| 737 | */ |
||
| 738 | 8 | public function diffReverse(array $array = array()) |
|
| 742 | |||
| 743 | /** |
||
| 744 | * Replace the first matched value in an array. |
||
| 745 | * |
||
| 746 | * @param mixed $search |
||
| 747 | * @param mixed $replacement |
||
| 748 | * |
||
| 749 | * @return Arrayy |
||
| 750 | */ |
||
| 751 | 3 | public function replaceOneValue($search, $replacement = '') |
|
| 762 | |||
| 763 | /** |
||
| 764 | * Replace values in the current array. |
||
| 765 | * |
||
| 766 | * @param string $search The string to replace. |
||
| 767 | * @param string $replacement What to replace it with. |
||
| 768 | * |
||
| 769 | * @return Arrayy |
||
| 770 | */ |
||
| 771 | 1 | public function replaceValues($search, $replacement = '') |
|
| 781 | |||
| 782 | /** |
||
| 783 | * Replace the keys in an array with another set. |
||
| 784 | * |
||
| 785 | * @param array $keys An array of keys matching the array's size |
||
| 786 | * |
||
| 787 | * @return Arrayy |
||
| 788 | */ |
||
| 789 | 1 | public function replaceKeys(array $keys) |
|
| 795 | |||
| 796 | /** |
||
| 797 | * Iterate over the current array and modify the array's value. |
||
| 798 | * |
||
| 799 | * @param \Closure $closure |
||
| 800 | * |
||
| 801 | * @return array |
||
| 802 | */ |
||
| 803 | 22 | public function each(\Closure $closure) |
|
| 813 | |||
| 814 | /** |
||
| 815 | * Shuffle the current array. |
||
| 816 | * |
||
| 817 | * @return Arrayy |
||
| 818 | */ |
||
| 819 | 1 | public function shuffle() |
|
| 827 | |||
| 828 | |||
| 829 | /** |
||
| 830 | * Split an array in the given amount of pieces. |
||
| 831 | * |
||
| 832 | * @param int $numberOfPieces |
||
| 833 | * @param bool $preserveKeys |
||
| 834 | * |
||
| 835 | * @return array |
||
| 836 | */ |
||
| 837 | 1 | public function split($numberOfPieces = 2, $preserveKeys = false) |
|
| 847 | |||
| 848 | /** |
||
| 849 | * Sort the current array by key. |
||
| 850 | * |
||
| 851 | * @param string $direction |
||
| 852 | * |
||
| 853 | * @return Arrayy |
||
| 854 | */ |
||
| 855 | 9 | public function sortKeys($direction = 'ASC') |
|
| 874 | |||
| 875 | /** |
||
| 876 | * Implodes an array. |
||
| 877 | * |
||
| 878 | * @param string $with What to implode it with |
||
| 879 | * |
||
| 880 | * @return string |
||
| 881 | */ |
||
| 882 | 22 | public function implode($with = '') |
|
| 886 | |||
| 887 | /** |
||
| 888 | * Returns the values from a single column of the input array, identified by |
||
| 889 | * the $columnKey, can be used to extract data-columns from multi-arrays. |
||
| 890 | * |
||
| 891 | * Info: Optionally, you may provide an $indexKey to index the values in the returned |
||
| 892 | * array by the values from the $indexKey column in the input array. |
||
| 893 | * |
||
| 894 | * @param mixed $columnKey |
||
| 895 | * @param mixed $indexKey |
||
| 896 | * |
||
| 897 | * @return Arrayy |
||
| 898 | */ |
||
| 899 | 1 | public function getColumn($columnKey = null, $indexKey = null) |
|
| 903 | |||
| 904 | /** |
||
| 905 | * Find all items in an array that pass the truth test. |
||
| 906 | * |
||
| 907 | * @param \Closure|null $closure |
||
| 908 | * |
||
| 909 | * @return Arrayy |
||
| 910 | */ |
||
| 911 | 8 | public function filter($closure = null) |
|
| 921 | |||
| 922 | /** |
||
| 923 | * Invoke a function on all of an array's values. |
||
| 924 | * |
||
| 925 | * @param mixed $callable |
||
| 926 | * @param array $arguments |
||
| 927 | * |
||
| 928 | * @return Arrayy |
||
| 929 | */ |
||
| 930 | 2 | public function invoke($callable, $arguments = array()) |
|
| 946 | |||
| 947 | /** |
||
| 948 | * Return all items that fail the truth test. |
||
| 949 | * |
||
| 950 | * @param \Closure $closure |
||
| 951 | * |
||
| 952 | * @return Arrayy |
||
| 953 | */ |
||
| 954 | 1 | View Code Duplication | public function reject(\Closure $closure) |
| 966 | |||
| 967 | /** |
||
| 968 | * Remove the first value from the current array. |
||
| 969 | * |
||
| 970 | * @return Arrayy |
||
| 971 | */ |
||
| 972 | 8 | public function removeFirst() |
|
| 978 | |||
| 979 | /** |
||
| 980 | * Remove the last value from the current array. |
||
| 981 | * |
||
| 982 | * @return Arrayy |
||
| 983 | */ |
||
| 984 | 7 | public function removeLast() |
|
| 990 | |||
| 991 | /** |
||
| 992 | * Removes a particular value from an array (numeric or associative). |
||
| 993 | * |
||
| 994 | * @param mixed $value |
||
| 995 | * |
||
| 996 | * @return Arrayy |
||
| 997 | */ |
||
| 998 | 7 | public function removeValue($value) |
|
| 1016 | |||
| 1017 | /** |
||
| 1018 | * Prepend a value to an array. |
||
| 1019 | * |
||
| 1020 | * @param mixed $value |
||
| 1021 | * |
||
| 1022 | * @return Arrayy |
||
| 1023 | */ |
||
| 1024 | 7 | public function prepend($value) |
|
| 1030 | |||
| 1031 | /** |
||
| 1032 | * Append a value to an array. |
||
| 1033 | * |
||
| 1034 | * @param mixed $value |
||
| 1035 | * |
||
| 1036 | * @return Arrayy |
||
| 1037 | */ |
||
| 1038 | 8 | public function append($value) |
|
| 1044 | |||
| 1045 | /** |
||
| 1046 | * Return the array in the reverse order. |
||
| 1047 | * |
||
| 1048 | * @return Arrayy |
||
| 1049 | */ |
||
| 1050 | 7 | public function reverse() |
|
| 1056 | |||
| 1057 | /** |
||
| 1058 | * Exchanges all keys with their associated values in an array. |
||
| 1059 | * |
||
| 1060 | * @return Arrayy |
||
| 1061 | */ |
||
| 1062 | 1 | public function flip() |
|
| 1068 | |||
| 1069 | /** |
||
| 1070 | * Reduce the current array via callable e.g. anonymous-function. |
||
| 1071 | * |
||
| 1072 | * @param mixed $predicate |
||
| 1073 | * @param array $init |
||
| 1074 | * |
||
| 1075 | * @return Arrayy |
||
| 1076 | */ |
||
| 1077 | 2 | public function reduce($predicate, array $init = array()) |
|
| 1083 | |||
| 1084 | /** |
||
| 1085 | * Return a duplicate free copy of the current array. |
||
| 1086 | * |
||
| 1087 | * @return Arrayy |
||
| 1088 | */ |
||
| 1089 | 7 | public function unique() |
|
| 1105 | |||
| 1106 | /** |
||
| 1107 | * Convert the current array to JSON. |
||
| 1108 | * |
||
| 1109 | * @param null $options e.g. JSON_PRETTY_PRINT |
||
| 1110 | * |
||
| 1111 | * @return string |
||
| 1112 | */ |
||
| 1113 | 1 | public function toJson($options = null) |
|
| 1117 | } |
||
| 1118 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.