@@ -90,7 +90,6 @@ |
||
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | /** |
| 93 | - * @param Project $project |
|
| 94 | 93 | * |
| 95 | 94 | * @return mixed |
| 96 | 95 | */ |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | $this->clients = array_merge($this->clients, $this->retrieveClientsForWorkspace($workspace->getId())); |
| 119 | 119 | $this->projects = array_merge($this->projects, $this->retrieveProjectsForWorkspace($workspace->getId())); |
| 120 | 120 | |
| 121 | - foreach($detailedReport->getData() as $timeEntry) { |
|
| 121 | + foreach ($detailedReport->getData() as $timeEntry) { |
|
| 122 | 122 | $timeEntrySent = false; |
| 123 | 123 | |
| 124 | 124 | if (in_array($timeEntry->getId(), $this->sentTimeEntries)) |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | if ($this->timeEntryCanBeLoggedByConfig($this->clients, $timeEntry->getClient(), $timeEntrySent)) { |
| 129 | 129 | $this->logTask($timeEntry, $this->clients, $timeEntry->getClient(), $this->projects, $timeEntry->getProject()); |
| 130 | 130 | |
| 131 | - $this->sentTimeEntries[] = $timeEntry->getId(); |
|
| 131 | + $this->sentTimeEntries[ ] = $timeEntry->getId(); |
|
| 132 | 132 | $timeEntrySent = true; |
| 133 | 133 | } |
| 134 | 134 | |
@@ -136,12 +136,12 @@ discard block |
||
| 136 | 136 | if ($this->timeEntryCanBeLoggedByConfig($this->projects, $timeEntry->getProject(), $timeEntrySent)) { |
| 137 | 137 | $this->logTask($timeEntry, $this->projects, $timeEntry->getProject()); |
| 138 | 138 | |
| 139 | - $this->sentTimeEntries[] = $timeEntry->getId(); |
|
| 139 | + $this->sentTimeEntries[ ] = $timeEntry->getId(); |
|
| 140 | 140 | $timeEntrySent = true; |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | if ($timeEntrySent) { |
| 144 | - $this->io->success('TimeEntry ('. $timeEntry->getDescription() . ') sent to InvoiceNinja'); |
|
| 144 | + $this->io->success('TimeEntry (' . $timeEntry->getDescription() . ') sent to InvoiceNinja'); |
|
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | 147 | } |
@@ -178,10 +178,10 @@ discard block |
||
| 178 | 178 | |
| 179 | 179 | $task->setDescription($this->buildTaskDescription($entry)); |
| 180 | 180 | $task->setTimeLog($this->buildTimeLog($entry)); |
| 181 | - $task->setClientId($clients[$clientKey]); |
|
| 181 | + $task->setClientId($clients[ $clientKey ]); |
|
| 182 | 182 | |
| 183 | 183 | if (isset($projects) && isset($projectKey)) |
| 184 | - $task->setProjectId($projects[$projectKey]); |
|
| 184 | + $task->setProjectId($projects[ $projectKey ]); |
|
| 185 | 185 | |
| 186 | 186 | $this->invoiceNinjaClient->saveNewTask($task); |
| 187 | 187 | } |
@@ -211,10 +211,10 @@ discard block |
||
| 211 | 211 | */ |
| 212 | 212 | private function buildTimeLog(TimeEntry $entry): string |
| 213 | 213 | { |
| 214 | - $timeLog = [[ |
|
| 214 | + $timeLog = [ [ |
|
| 215 | 215 | $entry->getStart()->getTimestamp(), |
| 216 | 216 | $entry->getEnd()->getTimestamp(), |
| 217 | - ]]; |
|
| 217 | + ] ]; |
|
| 218 | 218 | |
| 219 | 219 | return \GuzzleHttp\json_encode($timeLog); |
| 220 | 220 | } |
@@ -228,14 +228,14 @@ discard block |
||
| 228 | 228 | |
| 229 | 229 | foreach ($this->togglClients as $togglClient) |
| 230 | 230 | { |
| 231 | - if (!isset($this->projects[$togglProject->getName()])) |
|
| 231 | + if (!isset($this->projects[ $togglProject->getName() ])) |
|
| 232 | 232 | { |
| 233 | 233 | $found = false; |
| 234 | 234 | foreach ($invoiceNinjaClients as $invoiceNinjaClient) |
| 235 | 235 | { |
| 236 | 236 | if ($invoiceNinjaClient->getIsDeleted() == false && strcasecmp($togglClient->getName(), $invoiceNinjaClient->getName()) == 0) |
| 237 | 237 | { |
| 238 | - $clients[$invoiceNinjaClient->getName()] = $invoiceNinjaClient->getId(); |
|
| 238 | + $clients[ $invoiceNinjaClient->getName() ] = $invoiceNinjaClient->getId(); |
|
| 239 | 239 | $found = true; |
| 240 | 240 | } |
| 241 | 241 | } |
@@ -246,9 +246,9 @@ discard block |
||
| 246 | 246 | |
| 247 | 247 | $client->setName($togglClient->getName()); |
| 248 | 248 | |
| 249 | - $clients[$togglClient->getName()] = $this->invoiceNinjaClient->saveNewClient($client)->getId(); |
|
| 249 | + $clients[ $togglClient->getName() ] = $this->invoiceNinjaClient->saveNewClient($client)->getId(); |
|
| 250 | 250 | |
| 251 | - $this->io->success('Client ('. $togglClient->getName() . ') created in InvoiceNinja'); |
|
| 251 | + $this->io->success('Client (' . $togglClient->getName() . ') created in InvoiceNinja'); |
|
| 252 | 252 | } |
| 253 | 253 | } |
| 254 | 254 | } |
@@ -265,14 +265,14 @@ discard block |
||
| 265 | 265 | |
| 266 | 266 | foreach ($togglProjects as $togglProject) |
| 267 | 267 | { |
| 268 | - if (!isset($this->projects[$togglProject->getName()])) |
|
| 268 | + if (!isset($this->projects[ $togglProject->getName() ])) |
|
| 269 | 269 | { |
| 270 | 270 | $found = false; |
| 271 | 271 | foreach ($invoiceNinjaProjects as $invoiceNinjaProject) |
| 272 | 272 | { |
| 273 | 273 | if ($invoiceNinjaProject->getIsDeleted() == false && strcasecmp($togglProject->getName(), $invoiceNinjaProject->getName()) == 0) |
| 274 | 274 | { |
| 275 | - $projects[$invoiceNinjaProject->getName()] = $invoiceNinjaProject->getId(); |
|
| 275 | + $projects[ $invoiceNinjaProject->getName() ] = $invoiceNinjaProject->getId(); |
|
| 276 | 276 | $found = true; |
| 277 | 277 | } |
| 278 | 278 | } |
@@ -285,12 +285,12 @@ discard block |
||
| 285 | 285 | foreach ($this->togglClients as $togglClient) |
| 286 | 286 | { |
| 287 | 287 | if ($togglClient->getWid() == $workspaceId && $togglClient->getId() == $togglProject->getCid()) |
| 288 | - $project->setClientId($this->clients[$togglClient->getName()]); |
|
| 288 | + $project->setClientId($this->clients[ $togglClient->getName() ]); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | - $projects[$togglProject->getName()] = $this->invoiceNinjaClient->saveNewProject($project)->getId(); |
|
| 291 | + $projects[ $togglProject->getName() ] = $this->invoiceNinjaClient->saveNewProject($project)->getId(); |
|
| 292 | 292 | |
| 293 | - $this->io->success('Project ('. $togglProject->getName() . ') created in InvoiceNinja'); |
|
| 293 | + $this->io->success('Project (' . $togglProject->getName() . ') created in InvoiceNinja'); |
|
| 294 | 294 | } |
| 295 | 295 | } |
| 296 | 296 | } |
@@ -121,8 +121,9 @@ discard block |
||
| 121 | 121 | foreach($detailedReport->getData() as $timeEntry) { |
| 122 | 122 | $timeEntrySent = false; |
| 123 | 123 | |
| 124 | - if (in_array($timeEntry->getId(), $this->sentTimeEntries)) |
|
| 125 | - continue; |
|
| 124 | + if (in_array($timeEntry->getId(), $this->sentTimeEntries)) { |
|
| 125 | + continue; |
|
| 126 | + } |
|
| 126 | 127 | |
| 127 | 128 | // Log the entry if the client key exists |
| 128 | 129 | if ($this->timeEntryCanBeLoggedByConfig($this->clients, $timeEntry->getClient(), $timeEntrySent)) { |
@@ -180,8 +181,9 @@ discard block |
||
| 180 | 181 | $task->setTimeLog($this->buildTimeLog($entry)); |
| 181 | 182 | $task->setClientId($clients[$clientKey]); |
| 182 | 183 | |
| 183 | - if (isset($projects) && isset($projectKey)) |
|
| 184 | - $task->setProjectId($projects[$projectKey]); |
|
| 184 | + if (isset($projects) && isset($projectKey)) { |
|
| 185 | + $task->setProjectId($projects[$projectKey]); |
|
| 186 | + } |
|
| 185 | 187 | |
| 186 | 188 | $this->invoiceNinjaClient->saveNewTask($task); |
| 187 | 189 | } |
@@ -284,8 +286,9 @@ discard block |
||
| 284 | 286 | |
| 285 | 287 | foreach ($this->togglClients as $togglClient) |
| 286 | 288 | { |
| 287 | - if ($togglClient->getWid() == $workspaceId && $togglClient->getId() == $togglProject->getCid()) |
|
| 288 | - $project->setClientId($this->clients[$togglClient->getName()]); |
|
| 289 | + if ($togglClient->getWid() == $workspaceId && $togglClient->getId() == $togglProject->getCid()) { |
|
| 290 | + $project->setClientId($this->clients[$togglClient->getName()]); |
|
| 291 | + } |
|
| 289 | 292 | } |
| 290 | 293 | |
| 291 | 294 | $projects[$togglProject->getName()] = $this->invoiceNinjaClient->saveNewProject($project)->getId(); |
@@ -300,16 +303,19 @@ discard block |
||
| 300 | 303 | |
| 301 | 304 | private function retrieveSentTimeEntries() |
| 302 | 305 | { |
| 303 | - if (!file_exists($this->storageDir)) |
|
| 304 | - mkdir($this->storageDir, 0777, true); |
|
| 306 | + if (!file_exists($this->storageDir)) { |
|
| 307 | + mkdir($this->storageDir, 0777, true); |
|
| 308 | + } |
|
| 305 | 309 | |
| 306 | - if (!file_exists($this->storageDir . $this->storageFileName)) |
|
| 307 | - touch($this->storageDir . $this->storageFileName); |
|
| 310 | + if (!file_exists($this->storageDir . $this->storageFileName)) { |
|
| 311 | + touch($this->storageDir . $this->storageFileName); |
|
| 312 | + } |
|
| 308 | 313 | |
| 309 | 314 | $this->sentTimeEntries = unserialize(file_get_contents($this->storageDir . $this->storageFileName)); |
| 310 | 315 | |
| 311 | - if (!is_array($this->sentTimeEntries)) |
|
| 312 | - $this->sentTimeEntries = Array(); |
|
| 316 | + if (!is_array($this->sentTimeEntries)) { |
|
| 317 | + $this->sentTimeEntries = Array(); |
|
| 318 | + } |
|
| 313 | 319 | |
| 314 | 320 | return $this->sentTimeEntries; |
| 315 | 321 | } |
@@ -54,7 +54,7 @@ |
||
| 54 | 54 | public function getDetailedReport(int $workspaceId) |
| 55 | 55 | { |
| 56 | 56 | $res = $this->client->request('GET', self::VERSION . '/details', [ |
| 57 | - 'auth' => [$this->api_key, 'api_token'], |
|
| 57 | + 'auth' => [ $this->api_key, 'api_token' ], |
|
| 58 | 58 | 'query' => [ |
| 59 | 59 | 'user_agent' => '[email protected]', |
| 60 | 60 | 'workspace_id' => $workspaceId, |
@@ -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'); |