@@ -42,7 +42,7 @@ |
||
| 42 | 42 | $torrentsUrls = $this->getPopularTorrentsUrls($output, $weburgClient, $downloadDir); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - $this->dryRun($input, $output, function () use ($weburgClient, $torrentsDir, $torrentsUrls) { |
|
| 45 | + $this->dryRun($input, $output, function() use ($weburgClient, $torrentsDir, $torrentsUrls) { |
|
| 46 | 46 | foreach ($torrentsUrls as $torrentUrl) { |
| 47 | 47 | $weburgClient->downloadTorrent($torrentUrl, $torrentsDir); |
| 48 | 48 | } |
@@ -58,7 +58,7 @@ |
||
| 58 | 58 | $config->loadConfigFile(); |
| 59 | 59 | } catch (\RuntimeException $e) { |
| 60 | 60 | $logger->critical($e->getMessage()); |
| 61 | - $this->setCode(function () { |
|
| 61 | + $this->setCode(function() { |
|
| 62 | 62 | return 1; |
| 63 | 63 | }); |
| 64 | 64 | return; |
@@ -3,7 +3,6 @@ |
||
| 3 | 3 | namespace Popstas\Transmission\Console\Command; |
| 4 | 4 | |
| 5 | 5 | use GuzzleHttp; |
| 6 | -use InfluxDB; |
|
| 7 | 6 | use Martial\Transmission\API; |
| 8 | 7 | use Popstas\Transmission\Console; |
| 9 | 8 | use Popstas\Transmission\Console\Application; |
@@ -47,8 +47,8 @@ |
||
| 47 | 47 | ]; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - $cleanedIds = array_map(function ($torrentId) { |
|
| 51 | - return (int)$torrentId; |
|
| 50 | + $cleanedIds = array_map(function($torrentId) { |
|
| 51 | + return (int) $torrentId; |
|
| 52 | 52 | }, $ids); |
| 53 | 53 | |
| 54 | 54 | $this->createSession(); |
@@ -13,8 +13,7 @@ |
||
| 13 | 13 | public static function getTorrentAge($torrent) |
| 14 | 14 | { |
| 15 | 15 | $date = isset($torrent[Torrent\Get::DONE_DATE]) && $torrent[Torrent\Get::DONE_DATE] ? |
| 16 | - $torrent[Torrent\Get::DONE_DATE] : |
|
| 17 | - (isset($torrent[Torrent\Get::ADDED_DATE]) ? $torrent[Torrent\Get::ADDED_DATE] : 0); |
|
| 16 | + $torrent[Torrent\Get::DONE_DATE] : (isset($torrent[Torrent\Get::ADDED_DATE]) ? $torrent[Torrent\Get::ADDED_DATE] : 0); |
|
| 18 | 17 | return $date ? time() - $date : 0; |
| 19 | 18 | } |
| 20 | 19 | |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | { |
| 65 | 65 | $filters = self::parseFilters($filters); |
| 66 | 66 | |
| 67 | - return array_filter($rows, function ($row) use ($filters) { |
|
| 67 | + return array_filter($rows, function($row) use ($filters) { |
|
| 68 | 68 | foreach ($filters as $columnKey => $filter) { |
| 69 | 69 | if (!isset($row[$columnKey])) { |
| 70 | 70 | continue; |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | abs($columnNumber) |
| 111 | 111 | )) - 1; |
| 112 | 112 | |
| 113 | - usort($rowsSorted, function ($first, $second) use ($columnIndex, $sortOrder) { |
|
| 113 | + usort($rowsSorted, function($first, $second) use ($columnIndex, $sortOrder) { |
|
| 114 | 114 | return $first[$columnIndex] > $second[$columnIndex] ? $sortOrder : $sortOrder * -1; |
| 115 | 115 | }); |
| 116 | 116 | |
@@ -52,12 +52,12 @@ discard block |
||
| 52 | 52 | $config->get('influxdb-database') |
| 53 | 53 | ); |
| 54 | 54 | |
| 55 | - $lastDays = (int)$input->getOption('days') ? (int)$input->getOption('days') : 0; |
|
| 56 | - $limit = (int)$input->getOption('limit') ? (int)$input->getOption('limit') : 0; |
|
| 55 | + $lastDays = (int) $input->getOption('days') ? (int) $input->getOption('days') : 0; |
|
| 56 | + $limit = (int) $input->getOption('limit') ? (int) $input->getOption('limit') : 0; |
|
| 57 | 57 | |
| 58 | 58 | $torrentList = $client->getTorrentData(); |
| 59 | 59 | |
| 60 | - $torrentList = array_map(function ($torrent) { |
|
| 60 | + $torrentList = array_map(function($torrent) { |
|
| 61 | 61 | $torrent['age'] = TorrentUtils::getTorrentAgeInDays($torrent); |
| 62 | 62 | return $torrent; |
| 63 | 63 | }, $torrentList); |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | |
| 70 | 70 | $transmissionHost = $config->overrideConfig($input, 'transmission-host'); |
| 71 | 71 | |
| 72 | - $torrentList = array_map(function ($torrent) use ($influxDbClient, $transmissionHost, $lastDays) { |
|
| 72 | + $torrentList = array_map(function($torrent) use ($influxDbClient, $transmissionHost, $lastDays) { |
|
| 73 | 73 | $torrent['uploaded'] = $influxDbClient->getTorrentSum( |
| 74 | 74 | $torrent, |
| 75 | 75 | 'uploaded_last', |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | |
| 134 | 134 | private function removeTorrents(InputInterface $input, OutputInterface $output, array $rows) |
| 135 | 135 | { |
| 136 | - $limit = (int)$input->getOption('limit') ? (int)$input->getOption('limit') : 0; |
|
| 136 | + $limit = (int) $input->getOption('limit') ? (int) $input->getOption('limit') : 0; |
|
| 137 | 137 | |
| 138 | 138 | $rows = TableUtils::sortRowsByColumnNumber($rows, $input->getOption('sort')); |
| 139 | 139 | |
@@ -34,7 +34,7 @@ |
||
| 34 | 34 | |
| 35 | 35 | $torrentList = $client->getTorrentData(); |
| 36 | 36 | |
| 37 | - $torrentList = array_map(function ($torrent) { |
|
| 37 | + $torrentList = array_map(function($torrent) { |
|
| 38 | 38 | $torrent['age'] = TorrentUtils::getTorrentAgeInDays($torrent); |
| 39 | 39 | return $torrent; |
| 40 | 40 | }, $torrentList); |
@@ -63,6 +63,10 @@ discard block |
||
| 63 | 63 | $this->logger = $logger; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | + /** |
|
| 67 | + * @param string $level |
|
| 68 | + * @param string|null $message |
|
| 69 | + */ |
|
| 66 | 70 | private function log($level, $message, $context = []) |
| 67 | 71 | { |
| 68 | 72 | if (!is_null($this->logger)) { |
@@ -129,6 +133,9 @@ discard block |
||
| 129 | 133 | ); |
| 130 | 134 | } |
| 131 | 135 | |
| 136 | + /** |
|
| 137 | + * @param string $transmissionHost |
|
| 138 | + */ |
|
| 132 | 139 | public function getLastPoint(array $torrent, $transmissionHost) |
| 133 | 140 | { |
| 134 | 141 | $torrentName = $torrent[Torrent\Get::NAME]; |
@@ -64,7 +64,7 @@ |
||
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - $this->dryRun($input, $output, function () use ($influxDbClient, $points) { |
|
| 67 | + $this->dryRun($input, $output, function() use ($influxDbClient, $points) { |
|
| 68 | 68 | $influxDbClient->writePoints($points); |
| 69 | 69 | }, 'dry-run, don\'t really send points'); |
| 70 | 70 | } catch (\Exception $e) { |