@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | public function getWorkspaces() |
| 51 | 51 | { |
| 52 | 52 | $response = $this->client->request('GET', self::VERSION . '/workspaces', [ |
| 53 | - 'auth' => [$this->api_key, 'api_token'], |
|
| 53 | + 'auth' => [ $this->api_key, 'api_token' ], |
|
| 54 | 54 | ]); |
| 55 | 55 | |
| 56 | 56 | return $this->serializer->deserialize($response->getBody(), 'array<Syncer\Dto\Toggl\Workspace>', 'json'); |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | public function getClientsForWorkspace($workspaceId) |
| 63 | 63 | { |
| 64 | 64 | $response = $this->client->request('GET', self::VERSION . '/workspaces/' . $workspaceId . '/clients', [ |
| 65 | - 'auth' => [$this->api_key, 'api_token'], |
|
| 65 | + 'auth' => [ $this->api_key, 'api_token' ], |
|
| 66 | 66 | ]); |
| 67 | 67 | |
| 68 | 68 | return $this->serializer->deserialize($response->getBody(), 'array<Syncer\Dto\Toggl\Client>', 'json'); |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | public function getProjectsForWorkspace($workspaceId) |
| 75 | 75 | { |
| 76 | 76 | $response = $this->client->request('GET', self::VERSION . '/workspaces/' . $workspaceId . '/projects', [ |
| 77 | - 'auth' => [$this->api_key, 'api_token'], |
|
| 77 | + 'auth' => [ $this->api_key, 'api_token' ], |
|
| 78 | 78 | ]); |
| 79 | 79 | |
| 80 | 80 | return $this->serializer->deserialize($response->getBody(), 'array<Syncer\Dto\Toggl\Project>', 'json'); |
@@ -55,7 +55,7 @@ |
||
| 55 | 55 | public function getDetailedReport(int $workspaceId, int $sinceDaysAgo) |
| 56 | 56 | { |
| 57 | 57 | $res = $this->client->request('GET', self::VERSION . '/details', [ |
| 58 | - 'auth' => [$this->api_key, 'api_token'], |
|
| 58 | + 'auth' => [ $this->api_key, 'api_token' ], |
|
| 59 | 59 | 'query' => [ |
| 60 | 60 | 'user_agent' => '[email protected]', |
| 61 | 61 | 'workspace_id' => $workspaceId, |
@@ -96,8 +96,8 @@ discard block |
||
| 96 | 96 | $this->togglClient = $togglClient; |
| 97 | 97 | $this->reportsClient = $reportsClient; |
| 98 | 98 | $this->invoiceNinjaClient = $invoiceNinjaClient; |
| 99 | - $this->clients = $clients ?: []; |
|
| 100 | - $this->projects = $projects ?: []; |
|
| 99 | + $this->clients = $clients ?: [ ]; |
|
| 100 | + $this->projects = $projects ?: [ ]; |
|
| 101 | 101 | $this->storageDir = $storageDir; |
| 102 | 102 | $this->storageFileName = $storageFileName; |
| 103 | 103 | $this->useProjectsAsClients = $useProjectsAsClients ?: false; |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | $workspaceClients = array_merge($this->clients, $this->retrieveClientsForWorkspace($workspace->getId(), $this->clients)); |
| 139 | 139 | $workspaceProjects = array_merge($this->projects, $this->retrieveProjectsForWorkspace($workspace->getId(), $workspaceClients, $this->projects)); |
| 140 | 140 | |
| 141 | - foreach($detailedReport->getData() as $timeEntry) { |
|
| 141 | + foreach ($detailedReport->getData() as $timeEntry) { |
|
| 142 | 142 | $timeEntrySent = false; |
| 143 | 143 | $timeEntryClient = $timeEntry->getClient(); |
| 144 | 144 | $timeEntryProject = $timeEntry->getProject(); |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | } else if (!isset($timeEntryClient)) { |
| 155 | 155 | if ($this->useProjectsAsClients) { |
| 156 | 156 | $timeEntryClient = $timeEntryProject; |
| 157 | - $workspaceClients[$timeEntryProject] = $this->getInvoiceNinjaClientIdForProject($timeEntryProject); |
|
| 157 | + $workspaceClients[ $timeEntryProject ] = $this->getInvoiceNinjaClientIdForProject($timeEntryProject); |
|
| 158 | 158 | } else { |
| 159 | 159 | $timeEntryProject = NULL; |
| 160 | 160 | $this->io->warning('No client set for TimeEntry (' . $timeEntry->getDescription() . ')'); |
@@ -165,17 +165,17 @@ discard block |
||
| 165 | 165 | if (isset($timeEntryProject)) { |
| 166 | 166 | $this->logTask($timeEntry, $workspaceClients, $timeEntryClient, $workspaceProjects, $timeEntryProject); |
| 167 | 167 | |
| 168 | - $sentTimeEntries[] = $timeEntry->getId(); |
|
| 168 | + $sentTimeEntries[ ] = $timeEntry->getId(); |
|
| 169 | 169 | $timeEntrySent = true; |
| 170 | 170 | } else { |
| 171 | 171 | $this->logTask($timeEntry); |
| 172 | 172 | |
| 173 | - $sentTimeEntries[] = $timeEntry->getId(); |
|
| 173 | + $sentTimeEntries[ ] = $timeEntry->getId(); |
|
| 174 | 174 | $timeEntrySent = true; |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | if ($timeEntrySent) { |
| 178 | - $this->io->success('TimeEntry ('. $timeEntry->getDescription() . ') sent to InvoiceNinja'); |
|
| 178 | + $this->io->success('TimeEntry (' . $timeEntry->getDescription() . ') sent to InvoiceNinja'); |
|
| 179 | 179 | } |
| 180 | 180 | } |
| 181 | 181 | } |
@@ -197,11 +197,11 @@ discard block |
||
| 197 | 197 | $task->setDescription($this->buildTaskDescription($entry)); |
| 198 | 198 | $task->setTimeLog($this->buildTimeLog($entry)); |
| 199 | 199 | if (isset($clients) && isset($clientKey)) { |
| 200 | - $task->setClientId($clients[$clientKey]); |
|
| 200 | + $task->setClientId($clients[ $clientKey ]); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | if (isset($projects) && isset($projectKey)) { |
| 204 | - $task->setProjectId($projects[$projectKey]); |
|
| 204 | + $task->setProjectId($projects[ $projectKey ]); |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | $this->invoiceNinjaClient->saveNewTask($task); |
@@ -232,10 +232,10 @@ discard block |
||
| 232 | 232 | */ |
| 233 | 233 | private function buildTimeLog(TimeEntry $entry): string |
| 234 | 234 | { |
| 235 | - $timeLog = [[ |
|
| 235 | + $timeLog = [ [ |
|
| 236 | 236 | $entry->getStart()->getTimestamp(), |
| 237 | 237 | $entry->getEnd()->getTimestamp(), |
| 238 | - ]]; |
|
| 238 | + ] ]; |
|
| 239 | 239 | |
| 240 | 240 | return \GuzzleHttp\json_encode($timeLog); |
| 241 | 241 | } |
@@ -254,14 +254,14 @@ discard block |
||
| 254 | 254 | $togglClients = $this->togglClient->getClientsForWorkspace($workspaceId); |
| 255 | 255 | $invoiceNinjaClients = $this->invoiceNinjaClient->getClients(); |
| 256 | 256 | |
| 257 | - $clients = []; |
|
| 257 | + $clients = [ ]; |
|
| 258 | 258 | |
| 259 | 259 | foreach ($togglClients as $togglClient) { |
| 260 | - if (!isset($workspaceClients[$togglClient->getName()])) { |
|
| 260 | + if (!isset($workspaceClients[ $togglClient->getName() ])) { |
|
| 261 | 261 | $found = false; |
| 262 | 262 | foreach ($invoiceNinjaClients as $invoiceNinjaClient) { |
| 263 | 263 | if ($invoiceNinjaClient->getIsDeleted() == false && strcasecmp($togglClient->getName(), $invoiceNinjaClient->getName()) == 0) { |
| 264 | - $clients[$invoiceNinjaClient->getName()] = $invoiceNinjaClient->getId(); |
|
| 264 | + $clients[ $invoiceNinjaClient->getName() ] = $invoiceNinjaClient->getId(); |
|
| 265 | 265 | $found = true; |
| 266 | 266 | } |
| 267 | 267 | } |
@@ -270,9 +270,9 @@ discard block |
||
| 270 | 270 | |
| 271 | 271 | $client->setName($togglClient->getName()); |
| 272 | 272 | |
| 273 | - $clients[$togglClient->getName()] = $this->invoiceNinjaClient->saveNewClient($client)->getId(); |
|
| 273 | + $clients[ $togglClient->getName() ] = $this->invoiceNinjaClient->saveNewClient($client)->getId(); |
|
| 274 | 274 | |
| 275 | - $this->io->success('Client ('. $togglClient->getName() . ') created in InvoiceNinja'); |
|
| 275 | + $this->io->success('Client (' . $togglClient->getName() . ') created in InvoiceNinja'); |
|
| 276 | 276 | } |
| 277 | 277 | } |
| 278 | 278 | } |
@@ -296,14 +296,14 @@ discard block |
||
| 296 | 296 | $togglClients = $this->togglClient->getClientsForWorkspace($workspaceId); |
| 297 | 297 | $invoiceNinjaProjects = $this->invoiceNinjaClient->getProjects(); |
| 298 | 298 | |
| 299 | - $projects = []; |
|
| 299 | + $projects = [ ]; |
|
| 300 | 300 | |
| 301 | 301 | foreach ($togglProjects as $togglProject) { |
| 302 | - if (!isset($workspaceProjects[$togglProject->getName()])) { |
|
| 302 | + if (!isset($workspaceProjects[ $togglProject->getName() ])) { |
|
| 303 | 303 | $found = false; |
| 304 | 304 | foreach ($invoiceNinjaProjects as $invoiceNinjaProject) { |
| 305 | 305 | if ($invoiceNinjaProject->getIsDeleted() == false && strcasecmp($togglProject->getName(), $invoiceNinjaProject->getName()) == 0) { |
| 306 | - $projects[$invoiceNinjaProject->getName()] = $invoiceNinjaProject->getId(); |
|
| 306 | + $projects[ $invoiceNinjaProject->getName() ] = $invoiceNinjaProject->getId(); |
|
| 307 | 307 | $found = true; |
| 308 | 308 | } |
| 309 | 309 | } |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | if ($togglProject->getCid() !== NULL) { |
| 318 | 318 | foreach ($togglClients as $togglClient) { |
| 319 | 319 | if ($togglClient->getWid() == $workspaceId && $togglClient->getId() == $togglProject->getCid()) { |
| 320 | - $project->setClientId($workspaceClients[$togglClient->getName()]); |
|
| 320 | + $project->setClientId($workspaceClients[ $togglClient->getName() ]); |
|
| 321 | 321 | } |
| 322 | 322 | } |
| 323 | 323 | } else if ($this->useProjectsAsClients) { |
@@ -325,22 +325,22 @@ discard block |
||
| 325 | 325 | |
| 326 | 326 | $client->setName($togglProject->getName()); |
| 327 | 327 | |
| 328 | - $workspaceClients[$togglProject->getName()] = $this->invoiceNinjaClient->saveNewClient($client)->getId(); |
|
| 328 | + $workspaceClients[ $togglProject->getName() ] = $this->invoiceNinjaClient->saveNewClient($client)->getId(); |
|
| 329 | 329 | |
| 330 | - $this->io->success('Project ('. $togglProject->getName() . ') created as Client in InvoiceNinja'); |
|
| 330 | + $this->io->success('Project (' . $togglProject->getName() . ') created as Client in InvoiceNinja'); |
|
| 331 | 331 | |
| 332 | - $project->setClientId($workspaceClients[$togglProject->getName()]); |
|
| 332 | + $project->setClientId($workspaceClients[ $togglProject->getName() ]); |
|
| 333 | 333 | } else { |
| 334 | 334 | $clientPresent = false; |
| 335 | 335 | |
| 336 | - $this->io->error('Client not provided for Project ('. $togglProject->getName() . ') in Toggl'); |
|
| 336 | + $this->io->error('Client not provided for Project (' . $togglProject->getName() . ') in Toggl'); |
|
| 337 | 337 | $this->io->warning("To allow using projects as clients enable 'use_projects_as_clients' in parameters config file"); |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | if ($clientPresent) { |
| 341 | - $projects[$togglProject->getName()] = $this->invoiceNinjaClient->saveNewProject($project)->getId(); |
|
| 341 | + $projects[ $togglProject->getName() ] = $this->invoiceNinjaClient->saveNewProject($project)->getId(); |
|
| 342 | 342 | |
| 343 | - $this->io->success('Project ('. $togglProject->getName() . ') created in InvoiceNinja'); |
|
| 343 | + $this->io->success('Project (' . $togglProject->getName() . ') created in InvoiceNinja'); |
|
| 344 | 344 | } |
| 345 | 345 | } |
| 346 | 346 | } |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | */ |
| 357 | 357 | private function getInvoiceNinjaClientIdForProject(string $projectName): ?int |
| 358 | 358 | { |
| 359 | - $invoiceNinjaProjects = $this->invoiceNinjaClient->getProjects(); |
|
| 359 | + $invoiceNinjaProjects = $this->invoiceNinjaClient->getProjects(); |
|
| 360 | 360 | $invoiceNinjaClientId = NULL; |
| 361 | 361 | |
| 362 | 362 | foreach ($invoiceNinjaProjects as $invoiceNinjaProject) { |
@@ -386,7 +386,7 @@ discard block |
||
| 386 | 386 | $sentTimeEntries = unserialize(file_get_contents($this->storageDir . $this->storageFileName)); |
| 387 | 387 | |
| 388 | 388 | if (!is_array($sentTimeEntries)) { |
| 389 | - $sentTimeEntries = []; |
|
| 389 | + $sentTimeEntries = [ ]; |
|
| 390 | 390 | } |
| 391 | 391 | |
| 392 | 392 | return $sentTimeEntries; |