mathiasgrimm
Repos
27
Followers
49
Following
39

Events

Adding Arr::rotate() and Arr::rotateReverse()

Created at 2 weeks ago

Adding Arr::rotate() and Arr::rotateReverse()

Created at 2 weeks ago
pull request opened
Adding Arr::rotate and Arr::rotateReverse

Adding Arr::rotate and Arr:rotateReverse

// move first to last
Arr::rotate(['A', 'B', 'C']); 
// ['B', 'C', 'A']

// rotates twice
Arr::rotate(['A', 'B', 'C'], 2); 
// ['C', 'A', 'B']


// move last to first
Arr::rotateReverse(['A', 'B', 'C']);
// ['C', 'A', 'B']

// rotates twice
Arr::rotateReverse(['A', 'B', 'C'], 2); 
// ['B', 'C', 'A']

Example:

$queues = ['high', 'default', 'low'];
$command = "php artisan queue:listen --queue=";

for ($i = 0; $i < $workers; $i++) {
    // php artisan queue:listen --queue=high,default,low
    $currentCommand = $command . implode(',', $queues);
    $queues = Arr::rotate($queues);
    // $queues = ['default', 'low', 'high'];
}

Created at 2 weeks ago
create branch
mathiasgrimm create branch add-arr-rotate
Created at 2 weeks ago
Created at 2 weeks ago

updating doc

Created at 2 months ago
Created at 2 months ago