@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | $this->exif = $exif; |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - public function getTitle():?string |
|
| 23 | + public function getTitle(): ?string |
|
| 24 | 24 | { |
| 25 | 25 | $title = $this->exif->getTitle(); |
| 26 | 26 | if ($title === false) { |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | // JSON.) |
| 35 | 35 | return (string) $title; |
| 36 | 36 | } |
| 37 | - public function getDescription():?string |
|
| 37 | + public function getDescription(): ?string |
|
| 38 | 38 | { |
| 39 | 39 | $description = $this->exif->getCaption(); |
| 40 | 40 | if ($description === false) { |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | } |
| 43 | 43 | return (string) $description; |
| 44 | 44 | } |
| 45 | - public function getGPS():?array |
|
| 45 | + public function getGPS(): ?array |
|
| 46 | 46 | { |
| 47 | 47 | $gps = []; // Match the default in our Image entity |
| 48 | 48 | $gps_as_string = $this->exif->getGPS(); |
@@ -51,20 +51,20 @@ discard block |
||
| 51 | 51 | } |
| 52 | 52 | return $gps; |
| 53 | 53 | } |
| 54 | - public function getKeywords():?array |
|
| 54 | + public function getKeywords(): ?array |
|
| 55 | 55 | { |
| 56 | 56 | $keywords = $this->exif->getKeywords(); |
| 57 | 57 | if (is_string($keywords)) { |
| 58 | 58 | // A single keyword comes back as a simple string, not an array. We |
| 59 | 59 | // always return an array. |
| 60 | - $keywords = [ $keywords ]; |
|
| 60 | + $keywords = [$keywords]; |
|
| 61 | 61 | } |
| 62 | 62 | if (is_array($keywords)) { |
| 63 | 63 | return $keywords; |
| 64 | 64 | } |
| 65 | 65 | return []; // Match the default in our Image entity |
| 66 | 66 | } |
| 67 | - public function getCreationDate():?\DateTime |
|
| 67 | + public function getCreationDate(): ?\DateTime |
|
| 68 | 68 | { |
| 69 | 69 | $creationDate = $this->exif->getCreationDate(); |
| 70 | 70 | if ($creationDate instanceof \DateTime) { |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | } |
| 79 | 79 | return null; |
| 80 | 80 | } |
| 81 | - public function getRating():?int |
|
| 81 | + public function getRating(): ?int |
|
| 82 | 82 | { |
| 83 | 83 | $raw = $this->exif->getRawData(); |
| 84 | 84 | if (array_key_exists('XMP-xmp:Rating', $raw)) { |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | $token = $request->request->get('token'); |
| 81 | 81 | if (!$this->isCsrfTokenValid('image_upload', $token)) { |
| 82 | - return $this->json([ 'error' => 'Invalid CSRF token'], 401); |
|
| 82 | + return $this->json(['error' => 'Invalid CSRF token'], 401); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | $file = $request->files->get('file'); |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | // file we just uploaded*, thanks to the IGNORED_ATTRIBUTES. Because we set up the |
| 102 | 102 | // image URIs in a postPersist event listener, this also contains everything you'd |
| 103 | 103 | // need to build an image in HTML. |
| 104 | - return new JsonResponse($serializer->serialize($image, 'jsonld', [AbstractNormalizer::IGNORED_ATTRIBUTES => ['imageFile']]), 201,[], true); |
|
| 104 | + return new JsonResponse($serializer->serialize($image, 'jsonld', [AbstractNormalizer::IGNORED_ATTRIBUTES => ['imageFile']]), 201, [], true); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | // Normal GET request. |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | */ |
| 150 | 150 | public function delete(Request $request, Image $image): Response |
| 151 | 151 | { |
| 152 | - if ($this->isCsrfTokenValid('delete'.$image->getId(), $request->request->get('_token'))) { |
|
| 152 | + if ($this->isCsrfTokenValid('delete' . $image->getId(), $request->request->get('_token'))) { |
|
| 153 | 153 | $entityManager = $this->getDoctrine()->getManager(); |
| 154 | 154 | $entityManager->remove($image); |
| 155 | 155 | $entityManager->flush(); |
@@ -163,8 +163,8 @@ discard block |
||
| 163 | 163 | */ |
| 164 | 164 | public function setLocation(Request $request, Image $image, LocationService $locationService, EntityManagerInterface $entityManager): Response |
| 165 | 165 | { |
| 166 | - if ($this->isCsrfTokenValid('set_location'.$image->getId(), $request->request->get('_token'))) { |
|
| 167 | - $neighbourhood = $locationService->getLocationName($image->getLatitude(), $image->getLongitude()); |
|
| 166 | + if ($this->isCsrfTokenValid('set_location' . $image->getId(), $request->request->get('_token'))) { |
|
| 167 | + $neighbourhood = $locationService->getLocationName($image->getLatitude(), $image->getLongitude()); |
|
| 168 | 168 | if ($neighbourhood !== null) { |
| 169 | 169 | $image->setLocation($neighbourhood); |
| 170 | 170 | $entityManager->persist($image); |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | */ |
| 181 | 181 | public function setAutoTags(Request $request, Image $image, MessageBusInterface $messageBus): Response |
| 182 | 182 | { |
| 183 | - if ($this->isCsrfTokenValid('set_auto_tags'.$image->getId(), $request->request->get('_token'))) { |
|
| 183 | + if ($this->isCsrfTokenValid('set_auto_tags' . $image->getId(), $request->request->get('_token'))) { |
|
| 184 | 184 | $imageId = $image->getId(); |
| 185 | 185 | if ($imageId === null) { |
| 186 | 186 | throw new InvalidParameterException('No image id in setAutoTags'); |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | { |
| 36 | 36 | $fs = new Filesystem(); |
| 37 | 37 | $finder = new Finder(); |
| 38 | - foreach($finder->in(__DIR__ . '/gpx')->name('/\.gpx$/i') as $source) { |
|
| 38 | + foreach ($finder->in(__DIR__ . '/gpx')->name('/\.gpx$/i') as $source) { |
|
| 39 | 39 | $targetPath = sys_get_temp_dir() . '/' . $source->getFilename(); |
| 40 | 40 | $fs->copy($source->getPathname(), $targetPath); |
| 41 | 41 | $uploadedFile = $this->uploadHelper->uploadGpxFile(new File($targetPath)); |
@@ -49,7 +49,7 @@ |
||
| 49 | 49 | public function createSearchQueryBuilder(string $entityAlias): QueryBuilder { |
| 50 | 50 | $qb = $this->createQueryBuilder($entityAlias); |
| 51 | 51 | $qb->select($entityAlias, 'i') |
| 52 | - ->leftJoin($entityAlias.'.images', 'i'); |
|
| 52 | + ->leftJoin($entityAlias . '.images', 'i'); |
|
| 53 | 53 | return $qb; |
| 54 | 54 | } |
| 55 | 55 | |
@@ -36,7 +36,7 @@ |
||
| 36 | 36 | { |
| 37 | 37 | $fs = new Filesystem(); |
| 38 | 38 | $source = __DIR__ . '/gpx/01-APR-21 125735.GPX'; |
| 39 | - $targetPath = sys_get_temp_dir() . '/01-APR-21 125735.GPX'; |
|
| 39 | + $targetPath = sys_get_temp_dir() . '/01-APR-21 125735.GPX'; |
|
| 40 | 40 | $fs->copy($source, $targetPath); |
| 41 | 41 | $uploadedFile = $this->uploadHelper->uploadGpxFile(new File($targetPath)); |
| 42 | 42 | $wander = new Wander(); |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | { |
| 36 | 36 | $fs = new Filesystem(); |
| 37 | 37 | $finder = new Finder(); |
| 38 | - foreach($finder->in(__DIR__ . '/gpx/three')->name('/\.gpx$/i') as $source) { |
|
| 38 | + foreach ($finder->in(__DIR__ . '/gpx/three')->name('/\.gpx$/i') as $source) { |
|
| 39 | 39 | $targetPath = sys_get_temp_dir() . '/' . $source->getFilename(); |
| 40 | 40 | $fs->copy($source->getPathname(), $targetPath); |
| 41 | 41 | $uploadedFile = $this->uploadHelper->uploadGpxFile(new File($targetPath)); |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | $wander->setMinAltitude($stats->minAltitude); |
| 81 | 81 | $wander->setCumulativeElevationGain($stats->cumulativeElevationGain); |
| 82 | 82 | } |
| 83 | - catch(Exception $e) { |
|
| 83 | + catch (Exception $e) { |
|
| 84 | 84 | //$this->logger->debug("Couldn't set extended GPX property on wander: " . $e->getMessage()); |
| 85 | 85 | throw new Exception("Couldn't set standard GPX stats properties on wander.", 0, $e); |
| 86 | 86 | } |
@@ -111,10 +111,10 @@ discard block |
||
| 111 | 111 | public function compass(float $x, float $y): float |
| 112 | 112 | { |
| 113 | 113 | // https://www.php.net/manual/en/function.atan2.php#88119 |
| 114 | - if($x==0 AND $y==0){ return 0; } // ...or return 360 |
|
| 114 | + if ($x == 0 AND $y == 0) { return 0; } // ...or return 360 |
|
| 115 | 115 | return ($x < 0) |
| 116 | - ? rad2deg(atan2($x,$y)) + 360 |
|
| 117 | - : rad2deg(atan2($x,$y)); |
|
| 116 | + ? rad2deg(atan2($x, $y)) + 360 |
|
| 117 | + : rad2deg(atan2($x, $y)); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | public function gpxToGeoJson(string $gpx, float $epsilon, int $precision): string |
@@ -66,13 +66,13 @@ discard block |
||
| 66 | 66 | $validUris = []; |
| 67 | 67 | $wanders = $this->wanderRepository->findAll(); |
| 68 | 68 | foreach ($wanders as $wander) { |
| 69 | - $uri = $this->router->generate('wanders_show', [ 'id' => $wander->getId()], UrlGeneratorInterface::ABSOLUTE_URL); |
|
| 69 | + $uri = $this->router->generate('wanders_show', ['id' => $wander->getId()], UrlGeneratorInterface::ABSOLUTE_URL); |
|
| 70 | 70 | $validUris[$uri] = true; // Really I just want a hash that doesn't actually map |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | $images = $this->imageRepository->findAll(); |
| 74 | 74 | foreach ($images as $image) { |
| 75 | - $uri = $this->router->generate('image_show', [ 'id' => $image->getId()], UrlGeneratorInterface::ABSOLUTE_URL); |
|
| 75 | + $uri = $this->router->generate('image_show', ['id' => $image->getId()], UrlGeneratorInterface::ABSOLUTE_URL); |
|
| 76 | 76 | $validUris[$uri] = true; // Really I just want a hash that doesn't actually map |
| 77 | 77 | } |
| 78 | 78 | $homepage = $this->router->generate('home', [], RouterInterface::ABSOLUTE_URL); |
@@ -80,17 +80,17 @@ discard block |
||
| 80 | 80 | // Okay, now we've got a list of all valid URIs, let's have a look through all our descriptions |
| 81 | 81 | |
| 82 | 82 | // Wanders first... |
| 83 | - foreach($wanders as $wander) { |
|
| 83 | + foreach ($wanders as $wander) { |
|
| 84 | 84 | $description = $wander->getDescription(); |
| 85 | 85 | |
| 86 | 86 | // Broken links |
| 87 | - $links = $this->markdownService->findLinks($description); |
|
| 87 | + $links = $this->markdownService->findLinks($description); |
|
| 88 | 88 | foreach ($links as $link) { |
| 89 | 89 | if (substr($link['uri'], 0, strlen($homepage)) == $homepage) { |
| 90 | 90 | if (!array_key_exists($link['uri'], $validUris)) { |
| 91 | 91 | $problem = new Problem(); |
| 92 | 92 | $problem->setDescription('Wander ' . $wander->getId() . ' links to invalid URI: ' . $link['uri'] . ' (text is: "' . $link['text'] . '")'); |
| 93 | - $problem->setUri($this->router->generate('wanders_show', [ 'id' => $wander->getId()], UrlGeneratorInterface::ABSOLUTE_URL)); |
|
| 93 | + $problem->setUri($this->router->generate('wanders_show', ['id' => $wander->getId()], UrlGeneratorInterface::ABSOLUTE_URL)); |
|
| 94 | 94 | $this->entityManager->persist($problem); |
| 95 | 95 | } |
| 96 | 96 | } |
@@ -103,14 +103,14 @@ discard block |
||
| 103 | 103 | if (count($misspelledWords) > 0) { |
| 104 | 104 | $problem = new Problem(); |
| 105 | 105 | $problem->setDescription('Wander ' . $wander->getId() . ' has potential spelling mistakes: ' . implode(", ", $misspelledWords)); |
| 106 | - $problem->setUri($this->router->generate('wanders_show', [ 'id' => $wander->getId()], UrlGeneratorInterface::ABSOLUTE_URL)); |
|
| 106 | + $problem->setUri($this->router->generate('wanders_show', ['id' => $wander->getId()], UrlGeneratorInterface::ABSOLUTE_URL)); |
|
| 107 | 107 | $this->entityManager->persist($problem); |
| 108 | 108 | } |
| 109 | 109 | } |
| 110 | 110 | } |
| 111 | 111 | $this->entityManager->flush(); |
| 112 | 112 | // ...then Images: |
| 113 | - foreach($images as $image) { |
|
| 113 | + foreach ($images as $image) { |
|
| 114 | 114 | $description = $image->getDescription(); |
| 115 | 115 | |
| 116 | 116 | // Broken links |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | if (!array_key_exists($link['uri'], $validUris)) { |
| 121 | 121 | $problem = new Problem(); |
| 122 | 122 | $problem->setDescription('Image ' . $image->getId() . ' links to invalid URI: ' . $link['uri'] . ' (text is: "' . $link['text'] . '")'); |
| 123 | - $problem->setUri($this->router->generate('image_show', [ 'id' => $image->getId()], UrlGeneratorInterface::ABSOLUTE_URL)); |
|
| 123 | + $problem->setUri($this->router->generate('image_show', ['id' => $image->getId()], UrlGeneratorInterface::ABSOLUTE_URL)); |
|
| 124 | 124 | $this->entityManager->persist($problem); |
| 125 | 125 | } |
| 126 | 126 | } |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | if (count($misspelledWords) > 0) { |
| 134 | 134 | $problem = new Problem(); |
| 135 | 135 | $problem->setDescription('Image ' . $image->getId() . ' has potential spelling mistakes: ' . implode(", ", $misspelledWords)); |
| 136 | - $problem->setUri($this->router->generate('image_show', [ 'id' => $image->getId()], UrlGeneratorInterface::ABSOLUTE_URL)); |
|
| 136 | + $problem->setUri($this->router->generate('image_show', ['id' => $image->getId()], UrlGeneratorInterface::ABSOLUTE_URL)); |
|
| 137 | 137 | $this->entityManager->persist($problem); |
| 138 | 138 | } |
| 139 | 139 | } |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | public function checkString(string $input): array |
| 25 | 25 | { |
| 26 | 26 | $misspelledWords = []; |
| 27 | - $results = $this->aspell->checkText(new StringSource($input), ['en_GB', 'en']); |
|
| 27 | + $results = $this->aspell->checkText(new StringSource($input), ['en_GB', 'en']); |
|
| 28 | 28 | // TODO: Something functional |
| 29 | 29 | foreach ($results as $result) { |
| 30 | 30 | $misspelledWords[] = $result->word; |