@@ -90,7 +90,6 @@ |
||
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
93 | - * @param Project $project |
|
94 | 93 | * |
95 | 94 | * @return mixed |
96 | 95 | */ |
@@ -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'); |
@@ -9,7 +9,6 @@ |
||
9 | 9 | use Syncer\InvoiceNinja\InvoiceNinjaClient; |
10 | 10 | use Syncer\Toggl\ReportsClient; |
11 | 11 | use Syncer\Toggl\TogglClient; |
12 | - |
|
13 | 12 | use Symfony\Component\Console\Command\Command; |
14 | 13 | use Symfony\Component\Console\Input\InputInterface; |
15 | 14 | use Symfony\Component\Console\Output\OutputInterface; |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | $workspaceClients = array_merge($this->clients, $this->retrieveClientsForWorkspace($workspace->getId(), $this->clients)); |
131 | 131 | $workspaceProjects = array_merge($this->projects, $this->retrieveProjectsForWorkspace($workspace->getId(), $workspaceClients, $this->projects)); |
132 | 132 | |
133 | - foreach($detailedReport->getData() as $timeEntry) { |
|
133 | + foreach ($detailedReport->getData() as $timeEntry) { |
|
134 | 134 | $timeEntrySent = false; |
135 | 135 | $timeEntryClient = $timeEntry->getClient(); |
136 | 136 | $timeEntryProject = $timeEntry->getProject(); |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | else if (!isset($timeEntryClient)) { |
149 | 149 | if ($this->useProjectsAsClients) { |
150 | 150 | $timeEntryClient = $timeEntryProject; |
151 | - $workspaceClients[$timeEntryProject] = $this->getInvoiceNinjaClientIdForProject($timeEntryProject); |
|
151 | + $workspaceClients[ $timeEntryProject ] = $this->getInvoiceNinjaClientIdForProject($timeEntryProject); |
|
152 | 152 | } else { |
153 | 153 | $timeEntryProject = NULL; |
154 | 154 | $this->io->warning('No client set for TimeEntry (' . $timeEntry->getDescription() . ')'); |
@@ -159,17 +159,17 @@ discard block |
||
159 | 159 | if (isset($timeEntryProject)) { |
160 | 160 | $this->logTask($timeEntry, $workspaceClients, $timeEntryClient, $workspaceProjects, $timeEntryProject); |
161 | 161 | |
162 | - $this->sentTimeEntries[] = $timeEntry->getId(); |
|
162 | + $this->sentTimeEntries[ ] = $timeEntry->getId(); |
|
163 | 163 | $timeEntrySent = true; |
164 | 164 | } else { |
165 | 165 | $this->logTask($timeEntry); |
166 | 166 | |
167 | - $this->sentTimeEntries[] = $timeEntry->getId(); |
|
167 | + $this->sentTimeEntries[ ] = $timeEntry->getId(); |
|
168 | 168 | $timeEntrySent = true; |
169 | 169 | } |
170 | 170 | |
171 | 171 | if ($timeEntrySent) { |
172 | - $this->io->success('TimeEntry ('. $timeEntry->getDescription() . ') sent to InvoiceNinja'); |
|
172 | + $this->io->success('TimeEntry (' . $timeEntry->getDescription() . ') sent to InvoiceNinja'); |
|
173 | 173 | } |
174 | 174 | } |
175 | 175 | } |
@@ -191,11 +191,11 @@ discard block |
||
191 | 191 | $task->setDescription($this->buildTaskDescription($entry)); |
192 | 192 | $task->setTimeLog($this->buildTimeLog($entry)); |
193 | 193 | if (isset($clients) && isset($clientKey)) { |
194 | - $task->setClientId($clients[$clientKey]); |
|
194 | + $task->setClientId($clients[ $clientKey ]); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | if (isset($projects) && isset($projectKey)) { |
198 | - $task->setProjectId($projects[$projectKey]); |
|
198 | + $task->setProjectId($projects[ $projectKey ]); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | $this->invoiceNinjaClient->saveNewTask($task); |
@@ -226,10 +226,10 @@ discard block |
||
226 | 226 | */ |
227 | 227 | private function buildTimeLog(TimeEntry $entry): string |
228 | 228 | { |
229 | - $timeLog = [[ |
|
229 | + $timeLog = [ [ |
|
230 | 230 | $entry->getStart()->getTimestamp(), |
231 | 231 | $entry->getEnd()->getTimestamp(), |
232 | - ]]; |
|
232 | + ] ]; |
|
233 | 233 | |
234 | 234 | return \GuzzleHttp\json_encode($timeLog); |
235 | 235 | } |
@@ -248,14 +248,14 @@ discard block |
||
248 | 248 | $togglClients = $this->togglClient->getClientsForWorkspace($workspaceId); |
249 | 249 | $invoiceNinjaClients = $this->invoiceNinjaClient->getClients(); |
250 | 250 | |
251 | - $clients = []; |
|
251 | + $clients = [ ]; |
|
252 | 252 | |
253 | 253 | foreach ($togglClients as $togglClient) { |
254 | - if (!isset($workspaceClients[$togglClient->getName()])) { |
|
254 | + if (!isset($workspaceClients[ $togglClient->getName() ])) { |
|
255 | 255 | $found = false; |
256 | 256 | foreach ($invoiceNinjaClients as $invoiceNinjaClient) { |
257 | 257 | if ($invoiceNinjaClient->getIsDeleted() == false && strcasecmp($togglClient->getName(), $invoiceNinjaClient->getName()) == 0) { |
258 | - $clients[$invoiceNinjaClient->getName()] = $invoiceNinjaClient->getId(); |
|
258 | + $clients[ $invoiceNinjaClient->getName() ] = $invoiceNinjaClient->getId(); |
|
259 | 259 | $found = true; |
260 | 260 | } |
261 | 261 | } |
@@ -264,9 +264,9 @@ discard block |
||
264 | 264 | |
265 | 265 | $client->setName($togglClient->getName()); |
266 | 266 | |
267 | - $clients[$togglClient->getName()] = $this->invoiceNinjaClient->saveNewClient($client)->getId(); |
|
267 | + $clients[ $togglClient->getName() ] = $this->invoiceNinjaClient->saveNewClient($client)->getId(); |
|
268 | 268 | |
269 | - $this->io->success('Client ('. $togglClient->getName() . ') created in InvoiceNinja'); |
|
269 | + $this->io->success('Client (' . $togglClient->getName() . ') created in InvoiceNinja'); |
|
270 | 270 | } |
271 | 271 | } |
272 | 272 | } |
@@ -290,14 +290,14 @@ discard block |
||
290 | 290 | $togglClients = $this->togglClient->getClientsForWorkspace($workspaceId); |
291 | 291 | $invoiceNinjaProjects = $this->invoiceNinjaClient->getProjects(); |
292 | 292 | |
293 | - $projects = []; |
|
293 | + $projects = [ ]; |
|
294 | 294 | |
295 | 295 | foreach ($togglProjects as $togglProject) { |
296 | - if (!isset($workspaceProjects[$togglProject->getName()])) { |
|
296 | + if (!isset($workspaceProjects[ $togglProject->getName() ])) { |
|
297 | 297 | $found = false; |
298 | 298 | foreach ($invoiceNinjaProjects as $invoiceNinjaProject) { |
299 | 299 | if ($invoiceNinjaProject->getIsDeleted() == false && strcasecmp($togglProject->getName(), $invoiceNinjaProject->getName()) == 0) { |
300 | - $projects[$invoiceNinjaProject->getName()] = $invoiceNinjaProject->getId(); |
|
300 | + $projects[ $invoiceNinjaProject->getName() ] = $invoiceNinjaProject->getId(); |
|
301 | 301 | $found = true; |
302 | 302 | } |
303 | 303 | } |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | if ($togglProject->getCid() !== NULL) { |
312 | 312 | foreach ($togglClients as $togglClient) { |
313 | 313 | if ($togglClient->getWid() == $workspaceId && $togglClient->getId() == $togglProject->getCid()) { |
314 | - $project->setClientId($workspaceClients[$togglClient->getName()]); |
|
314 | + $project->setClientId($workspaceClients[ $togglClient->getName() ]); |
|
315 | 315 | } |
316 | 316 | } |
317 | 317 | } else if ($this->useProjectsAsClients) { |
@@ -319,20 +319,20 @@ discard block |
||
319 | 319 | |
320 | 320 | $client->setName($togglProject->getName()); |
321 | 321 | |
322 | - $workspaceClients[$togglProject->getName()] = $this->invoiceNinjaClient->saveNewClient($client)->getId(); |
|
322 | + $workspaceClients[ $togglProject->getName() ] = $this->invoiceNinjaClient->saveNewClient($client)->getId(); |
|
323 | 323 | |
324 | - $this->io->success('Project ('. $togglProject->getName() . ') created as Client in InvoiceNinja'); |
|
324 | + $this->io->success('Project (' . $togglProject->getName() . ') created as Client in InvoiceNinja'); |
|
325 | 325 | |
326 | - $project->setClientId($workspaceClients[$togglProject->getName()]); |
|
326 | + $project->setClientId($workspaceClients[ $togglProject->getName() ]); |
|
327 | 327 | } else { |
328 | - $this->io->error('Client not provided for Project ('. $togglProject->getName() . ') in Toggl'); |
|
328 | + $this->io->error('Client not provided for Project (' . $togglProject->getName() . ') in Toggl'); |
|
329 | 329 | $this->io->warning("To allow using projects as clients enable 'use_projects_as_clients' in parameters config file"); |
330 | 330 | } |
331 | 331 | |
332 | 332 | if ($clientPresent) { |
333 | - $projects[$togglProject->getName()] = $this->invoiceNinjaClient->saveNewProject($project)->getId(); |
|
333 | + $projects[ $togglProject->getName() ] = $this->invoiceNinjaClient->saveNewProject($project)->getId(); |
|
334 | 334 | |
335 | - $this->io->success('Project ('. $togglProject->getName() . ') created in InvoiceNinja'); |
|
335 | + $this->io->success('Project (' . $togglProject->getName() . ') created in InvoiceNinja'); |
|
336 | 336 | } |
337 | 337 | } |
338 | 338 | } |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | */ |
349 | 349 | private function getInvoiceNinjaClientIdForProject(string $projectName): ?int |
350 | 350 | { |
351 | - $invoiceNinjaProjects = $this->invoiceNinjaClient->getProjects(); |
|
351 | + $invoiceNinjaProjects = $this->invoiceNinjaClient->getProjects(); |
|
352 | 352 | $invoiceNinjaClientId = NULL; |
353 | 353 | |
354 | 354 | foreach ($invoiceNinjaProjects as $invoiceNinjaProject) { |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | $this->sentTimeEntries = unserialize(file_get_contents($this->storageDir . $this->storageFileName)); |
379 | 379 | |
380 | 380 | if (!is_array($this->sentTimeEntries)) { |
381 | - $this->sentTimeEntries = []; |
|
381 | + $this->sentTimeEntries = [ ]; |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | return $this->sentTimeEntries; |
@@ -143,9 +143,7 @@ |
||
143 | 143 | // a project is required, but a client is not. |
144 | 144 | if (!isset($timeEntryProject)) { |
145 | 145 | $this->io->warning('No project set for TimeEntry (' . $timeEntry->getDescription() . ')'); |
146 | - } |
|
147 | - |
|
148 | - else if (!isset($timeEntryClient)) { |
|
146 | + } else if (!isset($timeEntryClient)) { |
|
149 | 147 | if ($this->useProjectsAsClients) { |
150 | 148 | $timeEntryClient = $timeEntryProject; |
151 | 149 | $workspaceClients[$timeEntryProject] = $this->getInvoiceNinjaClientIdForProject($timeEntryProject); |