Skip to content

Commit

Permalink
Merge pull request #9 from exodus4d/develop
Browse files Browse the repository at this point in the history
v1.1.0
  • Loading branch information
exodus4d authored Apr 7, 2018
2 parents 9a3ff29 + 5c5aaac commit c706108
Show file tree
Hide file tree
Showing 2 changed files with 232 additions and 58 deletions.
37 changes: 37 additions & 0 deletions app/Main/Formatter/SubscriptionFormatter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
/**
* Created by PhpStorm.
* User: exodu
* Date: 31.03.2018
* Time: 13:09
*/

namespace Exodus4D\Socket\Main\Formatter;


class SubscriptionFormatter{

/**
* group charactersData by systemId based on their current 'log' data
* @param array $charactersData
* @return array
*/
static function groupCharactersDataBySystem(array $charactersData) : array {
$data = [];
foreach($charactersData as $characterId => $characterData){
// check if characterData has an active log (active system for character)
$systemId = (int)$characterData['log']['system']['id'];
if( !isset($data[$systemId]) ){
$systemData = (object)[];
$systemData->id = $systemId;
$data[$systemId] = $systemData;
}

$data[$systemId]->user[] = $characterData;
}
$data = array_values($data);

return $data;
}

}
Loading

0 comments on commit c706108

Please sign in to comment.