@@ -1,13 +1,13 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * This file is part of GitterBot package. |
|
| 4 | - * |
|
| 5 | - * @author Serafim <[email protected]> |
|
| 6 | - * @date 14.10.2015 11:21 |
|
| 7 | - * |
|
| 8 | - * For the full copyright and license information, please view the LICENSE |
|
| 9 | - * file that was distributed with this source code. |
|
| 10 | - */ |
|
| 3 | + * This file is part of GitterBot package. |
|
| 4 | + * |
|
| 5 | + * @author Serafim <[email protected]> |
|
| 6 | + * @date 14.10.2015 11:21 |
|
| 7 | + * |
|
| 8 | + * For the full copyright and license information, please view the LICENSE |
|
| 9 | + * file that was distributed with this source code. |
|
| 10 | + */ |
|
| 11 | 11 | namespace App\Http\Controllers\Api; |
| 12 | 12 | |
| 13 | 13 | use App\Achieve; |
@@ -27,20 +27,20 @@ |
||
| 27 | 27 | */ |
| 28 | 28 | public function index() |
| 29 | 29 | { |
| 30 | - return \Cache::remember('achievements', 10, function () { |
|
| 30 | + return \Cache::remember('achievements', 10, function() { |
|
| 31 | 31 | $achieveStorage = []; |
| 32 | 32 | |
| 33 | 33 | (new Achieve()) |
| 34 | 34 | ->selectRaw('name, count(user_id) as count') |
| 35 | 35 | ->groupBy('name') |
| 36 | 36 | ->get() |
| 37 | - ->each(function ($item) use (&$achieveStorage) { |
|
| 37 | + ->each(function($item) use (&$achieveStorage) { |
|
| 38 | 38 | $achieveStorage[$item->name] = $item->count; |
| 39 | 39 | }); |
| 40 | 40 | |
| 41 | 41 | return (new AchieveSubscriber()) |
| 42 | 42 | ->toCollection() |
| 43 | - ->each(function (AbstractAchieve $achieve) use ($achieveStorage) { |
|
| 43 | + ->each(function(AbstractAchieve $achieve) use ($achieveStorage) { |
|
| 44 | 44 | $achieve->users = $achieveStorage[$achieve->name] ?? 0; |
| 45 | 45 | }) |
| 46 | 46 | ->toArray(); |
@@ -1,13 +1,13 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * This file is part of GitterBot package. |
|
| 4 | - * |
|
| 5 | - * @author Serafim <[email protected]> |
|
| 6 | - * @date 14.10.2015 11:21 |
|
| 7 | - * |
|
| 8 | - * For the full copyright and license information, please view the LICENSE |
|
| 9 | - * file that was distributed with this source code. |
|
| 10 | - */ |
|
| 3 | + * This file is part of GitterBot package. |
|
| 4 | + * |
|
| 5 | + * @author Serafim <[email protected]> |
|
| 6 | + * @date 14.10.2015 11:21 |
|
| 7 | + * |
|
| 8 | + * For the full copyright and license information, please view the LICENSE |
|
| 9 | + * file that was distributed with this source code. |
|
| 10 | + */ |
|
| 11 | 11 | namespace App\Http\Controllers\Api; |
| 12 | 12 | |
| 13 | 13 | use App\Achieve; |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | public function index() |
| 28 | 28 | { |
| 29 | - return \Cache::remember('users', 1, function () { |
|
| 29 | + return \Cache::remember('users', 1, function() { |
|
| 30 | 30 | $karmaStorage = []; |
| 31 | 31 | $thanksStorage = []; |
| 32 | 32 | |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | ->selectRaw('user_target_id, count(user_id) as count') |
| 35 | 35 | ->groupBy('user_target_id') |
| 36 | 36 | ->get() |
| 37 | - ->each(function ($item) use (&$karmaStorage) { |
|
| 37 | + ->each(function($item) use (&$karmaStorage) { |
|
| 38 | 38 | $karmaStorage[$item->user_target_id] = $item->count; |
| 39 | 39 | }); |
| 40 | 40 | |
@@ -42,14 +42,14 @@ discard block |
||
| 42 | 42 | ->selectRaw('user_id, count(user_target_id) as count') |
| 43 | 43 | ->groupBy('user_id') |
| 44 | 44 | ->get() |
| 45 | - ->each(function ($item) use (&$thanksStorage) { |
|
| 45 | + ->each(function($item) use (&$thanksStorage) { |
|
| 46 | 46 | $thanksStorage[$item->user_id] = $item->count; |
| 47 | 47 | }); |
| 48 | 48 | |
| 49 | 49 | |
| 50 | 50 | return (new User()) |
| 51 | 51 | ->get(['id', 'login', 'name', 'gitter_id', 'avatar', 'url']) |
| 52 | - ->each(function (User $user) use ($karmaStorage, $thanksStorage) { |
|
| 52 | + ->each(function(User $user) use ($karmaStorage, $thanksStorage) { |
|
| 53 | 53 | $user->karma_count = $karmaStorage[$user->id] ?? 0; |
| 54 | 54 | $user->thanks_count = $thanksStorage[$user->id] ?? 0; |
| 55 | 55 | }); |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | public function getUsersTop() |
| 63 | 63 | { |
| 64 | - return \Cache::remember('top.karma', 1, function () { |
|
| 64 | + return \Cache::remember('top.karma', 1, function() { |
|
| 65 | 65 | $karmaStorage = []; |
| 66 | 66 | |
| 67 | 67 | $karma = (new Karma()) |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | ->orderBy('count', 'desc') |
| 71 | 71 | ->take(10) |
| 72 | 72 | ->get() |
| 73 | - ->each(function ($item) use (&$karmaStorage) { |
|
| 73 | + ->each(function($item) use (&$karmaStorage) { |
|
| 74 | 74 | $karmaStorage[$item->user_target_id] = $item->count; |
| 75 | 75 | }); |
| 76 | 76 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | return (new User()) |
| 79 | 79 | ->whereIn('id', $karma->pluck('user_target_id')) |
| 80 | 80 | ->get(['id', 'login', 'name', 'gitter_id', 'avatar', 'url']) |
| 81 | - ->each(function (User $user) use ($karmaStorage) { |
|
| 81 | + ->each(function(User $user) use ($karmaStorage) { |
|
| 82 | 82 | $user->karma_count = $karmaStorage[$user->id] ?? 0; |
| 83 | 83 | }); |
| 84 | 84 | }); |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | */ |
| 90 | 90 | public function getUser($gitterId) |
| 91 | 91 | { |
| 92 | - $formatRelations = function (HasMany $query) { |
|
| 92 | + $formatRelations = function(HasMany $query) { |
|
| 93 | 93 | return $query->orderBy('created_at', 'desc'); |
| 94 | 94 | }; |
| 95 | 95 | |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | Route::get('/achievements', 'HomeController@index'); |
| 9 | 9 | |
| 10 | 10 | |
| 11 | -Route::group(['prefix' => 'api', 'namespace' => 'Api'], function () { |
|
| 11 | +Route::group(['prefix' => 'api', 'namespace' => 'Api'], function() { |
|
| 12 | 12 | // Users |
| 13 | 13 | Route::get('users.json', 'UsersController@index'); |
| 14 | 14 | Route::get('users/top.json', 'UsersController@getUsersTop'); |
@@ -18,12 +18,12 @@ discard block |
||
| 18 | 18 | Route::get('achievements.json', 'AchievementsController@index'); |
| 19 | 19 | |
| 20 | 20 | |
| 21 | - Route::any('/{any}', function () { |
|
| 21 | + Route::any('/{any}', function() { |
|
| 22 | 22 | return ['error' => 'Not found']; |
| 23 | 23 | })->where('any', '.*?'); |
| 24 | 24 | }); |
| 25 | 25 | |
| 26 | 26 | |
| 27 | -Route::any('/{any}', function () { |
|
| 27 | +Route::any('/{any}', function() { |
|
| 28 | 28 | return Redirect::to('/'); |
| 29 | 29 | })->where('any', '.*?'); |
| 30 | 30 | \ No newline at end of file |
@@ -69,7 +69,7 @@ |
||
| 69 | 69 | * @param int $lifeTime The cache lifetime. |
| 70 | 70 | * If != 0, sets a specific lifetime for this cache entry (0 => infinite lifeTime). |
| 71 | 71 | * |
| 72 | - * @return boolean TRUE if the entry was successfully stored in the cache, FALSE otherwise. |
|
| 72 | + * @return boolean|null TRUE if the entry was successfully stored in the cache, FALSE otherwise. |
|
| 73 | 73 | */ |
| 74 | 74 | public function save($id, $data, $lifeTime = 0) |
| 75 | 75 | { |
@@ -1,14 +1,14 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | declare(strict_types = 1); |
| 3 | 3 | /** |
| 4 | - * This file is part of GitterBot package. |
|
| 5 | - * |
|
| 6 | - * @author Serafim <[email protected]> |
|
| 7 | - * @date 03.03.2016 15:08 |
|
| 8 | - * |
|
| 9 | - * For the full copyright and license information, please view the LICENSE |
|
| 10 | - * file that was distributed with this source code. |
|
| 11 | - */ |
|
| 4 | + * This file is part of GitterBot package. |
|
| 5 | + * |
|
| 6 | + * @author Serafim <[email protected]> |
|
| 7 | + * @date 03.03.2016 15:08 |
|
| 8 | + * |
|
| 9 | + * For the full copyright and license information, please view the LICENSE |
|
| 10 | + * file that was distributed with this source code. |
|
| 11 | + */ |
|
| 12 | 12 | |
| 13 | 13 | |
| 14 | 14 | namespace Core\Doctrine; |
@@ -13,7 +13,6 @@ |
||
| 13 | 13 | use Carbon\Carbon; |
| 14 | 14 | use Core\Mappers\UserMapper; |
| 15 | 15 | use Domains\Message; |
| 16 | -use Domains\User; |
|
| 17 | 16 | use Gitter\Client; |
| 18 | 17 | use Gitter\Support\ApiIterator; |
| 19 | 18 | use Illuminate\Console\Command; |
@@ -1,13 +1,13 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * This file is part of GitterBot package. |
|
| 4 | - * |
|
| 5 | - * @author Serafim <[email protected]> |
|
| 6 | - * @date 24.09.2015 15:27 |
|
| 7 | - * |
|
| 8 | - * For the full copyright and license information, please view the LICENSE |
|
| 9 | - * file that was distributed with this source code. |
|
| 10 | - */ |
|
| 3 | + * This file is part of GitterBot package. |
|
| 4 | + * |
|
| 5 | + * @author Serafim <[email protected]> |
|
| 6 | + * @date 24.09.2015 15:27 |
|
| 7 | + * |
|
| 8 | + * For the full copyright and license information, please view the LICENSE |
|
| 9 | + * file that was distributed with this source code. |
|
| 10 | + */ |
|
| 11 | 11 | |
| 12 | 12 | namespace App\Gitter\Middleware; |
| 13 | 13 | |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | |
| 61 | 61 | // Sync users |
| 62 | - $db->transaction(function () use ($container) { |
|
| 62 | + $db->transaction(function() use ($container) { |
|
| 63 | 63 | $this->comment('Start users synchronize at ' . ($start = Carbon::now())); |
| 64 | 64 | $container->call([$this, 'importUsers']); |
| 65 | 65 | $this->comment('Ends ' . Carbon::now()->diffForHumans($start)); |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | |
| 72 | 72 | // Sync messages |
| 73 | - $db->transaction(function () use ($container) { |
|
| 73 | + $db->transaction(function() use ($container) { |
|
| 74 | 74 | $this->comment('Start messages synchronize at ' . ($start = Carbon::now())); |
| 75 | 75 | $container->call([$this, 'importMessages']); |
| 76 | 76 | $this->comment('Ends ' . Carbon::now()->diffForHumans($start)); |
@@ -93,14 +93,14 @@ discard block |
||
| 93 | 93 | $rootTimeZone = new \DateTimeZone('UTC'); |
| 94 | 94 | |
| 95 | 95 | |
| 96 | - $messages = new ApiIterator(function ($page) use ($client, $room, $limit, &$lastMessageId) { |
|
| 96 | + $messages = new ApiIterator(function($page) use ($client, $room, $limit, &$lastMessageId) { |
|
| 97 | 97 | $query = ['limit' => $limit]; |
| 98 | 98 | |
| 99 | 99 | if ($lastMessageId !== null) { |
| 100 | 100 | $query['beforeId'] = $lastMessageId; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - $result = $this->rescue(function () use ($room, $query, $client) { |
|
| 103 | + $result = $this->rescue(function() use ($room, $query, $client) { |
|
| 104 | 104 | return $client->http->getMessages($room->id, $query)->wait(); |
| 105 | 105 | }); |
| 106 | 106 | |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | */ |
| 137 | 137 | try { |
| 138 | 138 | |
| 139 | - $db->transaction(function () use ($message, $data, $db) { |
|
| 139 | + $db->transaction(function() use ($message, $data, $db) { |
|
| 140 | 140 | $db->table('messages')->where('gitter_id', $data['gitter_id'])->delete(); |
| 141 | 141 | $db->table('messages')->insert($data); |
| 142 | 142 | |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | */ |
| 177 | 177 | private function getRoom(Client $client) |
| 178 | 178 | { |
| 179 | - return $this->rescue(function () use ($client) { |
|
| 179 | + return $this->rescue(function() use ($client) { |
|
| 180 | 180 | return $client->http->getRoomById($this->argument('room'))->wait(); |
| 181 | 181 | }); |
| 182 | 182 | } |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | { |
| 193 | 193 | return (new Evacuator($request)) |
| 194 | 194 | ->retry(Evacuator::INFINITY_RETRIES) |
| 195 | - ->catch(function (\Throwable $e) { |
|
| 195 | + ->catch(function(\Throwable $e) { |
|
| 196 | 196 | $this->error($e->getMessage() . "\n" . '// retry again'); |
| 197 | 197 | sleep(1); |
| 198 | 198 | }) |
@@ -210,8 +210,8 @@ discard block |
||
| 210 | 210 | $room = $this->getRoom($client); |
| 211 | 211 | |
| 212 | 212 | |
| 213 | - $users = new ApiIterator(function ($page) use ($client, $room) { |
|
| 214 | - return $this->rescue(function () use ($room, $page, $client) { |
|
| 213 | + $users = new ApiIterator(function($page) use ($client, $room) { |
|
| 214 | + return $this->rescue(function() use ($room, $page, $client) { |
|
| 215 | 215 | |
| 216 | 216 | return $client->http->getRoomUsers($room->id, ['limit' => 30, 'skip' => 30 * $page])->wait(); |
| 217 | 217 | |
@@ -1,14 +1,14 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | declare(strict_types = 1); |
| 3 | 3 | /** |
| 4 | - * This file is part of GitterBot package. |
|
| 5 | - * |
|
| 6 | - * @author Serafim <[email protected]> |
|
| 7 | - * @date 28.03.2016 14:35 |
|
| 8 | - * |
|
| 9 | - * For the full copyright and license information, please view the LICENSE |
|
| 10 | - * file that was distributed with this source code. |
|
| 11 | - */ |
|
| 4 | + * This file is part of GitterBot package. |
|
| 5 | + * |
|
| 6 | + * @author Serafim <[email protected]> |
|
| 7 | + * @date 28.03.2016 14:35 |
|
| 8 | + * |
|
| 9 | + * For the full copyright and license information, please view the LICENSE |
|
| 10 | + * file that was distributed with this source code. |
|
| 11 | + */ |
|
| 12 | 12 | namespace Domains\Message; |
| 13 | 13 | |
| 14 | 14 | use Core\Mappers\Message\UrlMapper; |
@@ -48,7 +48,7 @@ |
||
| 48 | 48 | |
| 49 | 49 | preg_match_all('/\w+/iu', $text, $words, PREG_PATTERN_ORDER); |
| 50 | 50 | |
| 51 | - return array_map(function ($word) { |
|
| 51 | + return array_map(function($word) { |
|
| 52 | 52 | return mb_strtolower($word); |
| 53 | 53 | }, $words[0]); |
| 54 | 54 | } |
@@ -1,14 +1,14 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | declare(strict_types = 1); |
| 3 | 3 | /** |
| 4 | - * This file is part of GitterBot package. |
|
| 5 | - * |
|
| 6 | - * @author Serafim <[email protected]> |
|
| 7 | - * @date 28.03.2016 14:06 |
|
| 8 | - * |
|
| 9 | - * For the full copyright and license information, please view the LICENSE |
|
| 10 | - * file that was distributed with this source code. |
|
| 11 | - */ |
|
| 4 | + * This file is part of GitterBot package. |
|
| 5 | + * |
|
| 6 | + * @author Serafim <[email protected]> |
|
| 7 | + * @date 28.03.2016 14:06 |
|
| 8 | + * |
|
| 9 | + * For the full copyright and license information, please view the LICENSE |
|
| 10 | + * file that was distributed with this source code. |
|
| 11 | + */ |
|
| 12 | 12 | namespace Core\Mappers\Message; |
| 13 | 13 | |
| 14 | 14 | use Domains\Message\Message; |
@@ -1,14 +1,14 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | declare(strict_types = 1); |
| 3 | 3 | /** |
| 4 | - * This file is part of GitterBot package. |
|
| 5 | - * |
|
| 6 | - * @author Serafim <[email protected]> |
|
| 7 | - * @date 28.03.2016 14:25 |
|
| 8 | - * |
|
| 9 | - * For the full copyright and license information, please view the LICENSE |
|
| 10 | - * file that was distributed with this source code. |
|
| 11 | - */ |
|
| 4 | + * This file is part of GitterBot package. |
|
| 5 | + * |
|
| 6 | + * @author Serafim <[email protected]> |
|
| 7 | + * @date 28.03.2016 14:25 |
|
| 8 | + * |
|
| 9 | + * For the full copyright and license information, please view the LICENSE |
|
| 10 | + * file that was distributed with this source code. |
|
| 11 | + */ |
|
| 12 | 12 | |
| 13 | 13 | namespace Domains\User; |
| 14 | 14 | |
@@ -1,14 +1,14 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | declare(strict_types = 1); |
| 3 | 3 | /** |
| 4 | - * This file is part of GitterBot package. |
|
| 5 | - * |
|
| 6 | - * @author Serafim <[email protected]> |
|
| 7 | - * @date 23.03.2016 20:17 |
|
| 8 | - * |
|
| 9 | - * For the full copyright and license information, please view the LICENSE |
|
| 10 | - * file that was distributed with this source code. |
|
| 11 | - */ |
|
| 4 | + * This file is part of GitterBot package. |
|
| 5 | + * |
|
| 6 | + * @author Serafim <[email protected]> |
|
| 7 | + * @date 23.03.2016 20:17 |
|
| 8 | + * |
|
| 9 | + * For the full copyright and license information, please view the LICENSE |
|
| 10 | + * file that was distributed with this source code. |
|
| 11 | + */ |
|
| 12 | 12 | namespace Domains\User; |
| 13 | 13 | |
| 14 | 14 | use Carbon\Carbon; |