| @@ 52-63 (lines=12) @@ | ||
| 49 | * |
|
| 50 | * @return void |
|
| 51 | */ |
|
| 52 | public static function copyIfKeysExist(array $source, array &$dest, array $keyMap) |
|
| 53 | { |
|
| 54 | foreach ($keyMap as $destKey => $sourceKey) { |
|
| 55 | if (is_int($destKey)) { |
|
| 56 | $destKey = $sourceKey; |
|
| 57 | } |
|
| 58 | ||
| 59 | if (array_key_exists($sourceKey, $source)) { |
|
| 60 | $dest[$destKey] = $source[$sourceKey]; |
|
| 61 | } |
|
| 62 | } |
|
| 63 | } |
|
| 64 | ||
| 65 | /** |
|
| 66 | * Sets destination array values to be the source values if the source key is set in the source array. |
|
| @@ 75-86 (lines=12) @@ | ||
| 72 | * |
|
| 73 | * @return void |
|
| 74 | */ |
|
| 75 | public static function copyIfSet(array $source, array &$dest, array $keyMap) |
|
| 76 | { |
|
| 77 | foreach ($keyMap as $destKey => $sourceKey) { |
|
| 78 | if (is_int($destKey)) { |
|
| 79 | $destKey = $sourceKey; |
|
| 80 | } |
|
| 81 | ||
| 82 | if (isset($source[$sourceKey])) { |
|
| 83 | $dest[$destKey] = $source[$sourceKey]; |
|
| 84 | } |
|
| 85 | } |
|
| 86 | } |
|
| 87 | ||
| 88 | /** |
|
| 89 | * Returns true and fills $value if $key exists in $array, otherwise fills $value with null and returns false |
|