-
-
Notifications
You must be signed in to change notification settings - Fork 38
feat: writes a key/value set to two columns in a row #99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
adhocore
merged 5 commits into
adhocore:main
from
dimtrovich:feat-write-in-two-columns-side
Mar 28, 2024
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
22cd2c4
feat: writes a key/value set to two columns in a row
dimtrovich 2fdabc1
update readme to add docs of twoColumnDetail method
dimtrovich 8bb6697
patch: restore existing docs
dimtrovich 24f2e22
patch: remove unecessary helper
dimtrovich 6fa0191
refactor: change twoColumnsDetail to justify
dimtrovich File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the PHP-CLI package. | ||
* | ||
* (c) Jitendra Adhikari <[email protected]> | ||
* <https://github.com/adhocore> | ||
* | ||
* Licensed under MIT license. | ||
*/ | ||
|
||
namespace Ahc\Cli\Helper; | ||
|
||
use function current; | ||
use function func_get_args; | ||
use function is_array; | ||
use function is_int; | ||
use function next; | ||
|
||
/** | ||
* helper specializing in table manipulation | ||
* | ||
* @author Dimitri Sitchet Tomkeu <[email protected]> | ||
* @license MIT | ||
* | ||
* @link https://github.com/adhocore/cli | ||
*/ | ||
class Arr | ||
adhocore marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
/** | ||
* This function can be thought of as a hybrid between PHP's `array_merge` and `array_merge_recursive`. | ||
* | ||
* The difference between this method and the built-in ones, is that if an array key contains another array, then | ||
* Hash::merge() will behave in a recursive fashion (unlike `array_merge`). But it will not act recursively for | ||
* keys that contain scalar values (unlike `array_merge_recursive`). | ||
* | ||
* Note: This function will work with an unlimited amount of arguments and typecasts non-array parameters into arrays. | ||
* | ||
* @param array $data Array to be merged | ||
* @param mixed $merge Array to merge with. The argument and all trailing arguments will be array cast when merged | ||
* | ||
* @return array Merged array | ||
* | ||
* @credit CakePHP - http://book.cakephp.org/2.0/en/core-utility-libraries/hash.html#Hash::merge | ||
*/ | ||
public static function merge(array $data, $merge) | ||
adhocore marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
$args = func_get_args(); | ||
$return = current($args); | ||
|
||
while (($arg = next($args)) !== false) { | ||
foreach ((array) $arg as $key => $val) { | ||
if (! empty($return[$key]) && is_array($return[$key]) && is_array($val)) { | ||
$return[$key] = self::merge($return[$key], $val); | ||
} elseif (is_int($key) && isset($return[$key])) { | ||
$return[] = $val; | ||
} else { | ||
$return[$key] = $val; | ||
} | ||
} | ||
} | ||
|
||
return $return; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.