| @@ 80-91 (lines=12) @@ | ||
| 77 | * |
|
| 78 | * @return void |
|
| 79 | */ |
|
| 80 | public static function copyIfKeysExist(array $source, array &$dest, array $keyMap) |
|
| 81 | { |
|
| 82 | foreach ($keyMap as $destKey => $sourceKey) { |
|
| 83 | if (is_int($destKey)) { |
|
| 84 | $destKey = $sourceKey; |
|
| 85 | } |
|
| 86 | ||
| 87 | if (array_key_exists($sourceKey, $source)) { |
|
| 88 | $dest[$destKey] = $source[$sourceKey]; |
|
| 89 | } |
|
| 90 | } |
|
| 91 | } |
|
| 92 | ||
| 93 | /** |
|
| 94 | * Sets destination array values to be the source values if the source key is set in the source array. |
|
| @@ 103-114 (lines=12) @@ | ||
| 100 | * |
|
| 101 | * @return void |
|
| 102 | */ |
|
| 103 | public static function copyIfSet(array $source, array &$dest, array $keyMap) |
|
| 104 | { |
|
| 105 | foreach ($keyMap as $destKey => $sourceKey) { |
|
| 106 | if (is_int($destKey)) { |
|
| 107 | $destKey = $sourceKey; |
|
| 108 | } |
|
| 109 | ||
| 110 | if (isset($source[$sourceKey])) { |
|
| 111 | $dest[$destKey] = $source[$sourceKey]; |
|
| 112 | } |
|
| 113 | } |
|
| 114 | } |
|
| 115 | ||
| 116 | /** |
|
| 117 | * Returns true and fills $value if $key exists in $array, otherwise fills $value with null and returns false |
|