| @@ -4,13 +4,13 @@ | ||
| 4 | 4 | $container = $app->getContainer(); | 
| 5 | 5 | |
| 6 | 6 | // view renderer | 
| 7 | -$container['renderer'] = function ($c) { | |
| 7 | +$container['renderer'] = function($c) { | |
| 8 | 8 |      $settings = $c->get('settings')['renderer']; | 
| 9 | 9 | return new Slim\Views\PhpRenderer($settings['template_path']); | 
| 10 | 10 | }; | 
| 11 | 11 | |
| 12 | 12 | // monolog | 
| 13 | -$container['logger'] = function ($c) { | |
| 13 | +$container['logger'] = function($c) { | |
| 14 | 14 |      $settings = $c->get('settings')['logger']; | 
| 15 | 15 | $logger = new Monolog\Logger($settings['name']); | 
| 16 | 16 | $logger->pushProcessor(new Monolog\Processor\UidProcessor()); | 
| @@ -33,7 +33,7 @@ | ||
| 33 | 33 | |
| 34 | 34 | public function add(Cfp $cfp) | 
| 35 | 35 |      { | 
| 36 | -        if (! $this->has($cfp)) { | |
| 36 | +        if (!$this->has($cfp)) { | |
| 37 | 37 | $this->cfps[] = $cfp; | 
| 38 | 38 | } | 
| 39 | 39 | } | 
| @@ -68,7 +68,7 @@ discard block | ||
| 68 | 68 | } | 
| 69 | 69 | |
| 70 | 70 |          $bearer = explode(' ', $auth[0]); | 
| 71 | -        if (! isset($bearer[1])) { | |
| 71 | +        if (!isset($bearer[1])) { | |
| 72 | 72 | return $this->getNoAuthResponse($response); | 
| 73 | 73 | } | 
| 74 | 74 | $bearer = $bearer[1]; | 
| @@ -87,7 +87,7 @@ discard block | ||
| 87 | 87 | |
| 88 | 88 | protected function getNoAuthResponse($response, $error = 'no token', $description = 'No Access-Token provided') | 
| 89 | 89 |      { | 
| 90 | -        $response = $response->withHeader('WWW-Authenticate', 'Bearer realm="callingallpapers", error="' . $error . '", error_desciption="' . $description . '"'); | |
| 90 | +        $response = $response->withHeader('WWW-Authenticate', 'Bearer realm="callingallpapers", error="'.$error.'", error_desciption="'.$description.'"'); | |
| 91 | 91 | $response = $response->withStatus(401); | 
| 92 | 92 | |
| 93 | 93 | return $response; | 
| @@ -56,7 +56,7 @@ | ||
| 56 | 56 | 'uri' => 'http://andreas.heigl.org', | 
| 57 | 57 | ]); | 
| 58 | 58 | $feed->setDateModified(time()); | 
| 59 | -        if (! isset($data['cfps'])) { | |
| 59 | +        if (!isset($data['cfps'])) { | |
| 60 | 60 | $data['cfps'] = []; | 
| 61 | 61 | } | 
| 62 | 62 |          foreach ($data['cfps'] as $cfp) { | 
| @@ -36,7 +36,7 @@ | ||
| 36 | 36 |  { | 
| 37 | 37 | /** | 
| 38 | 38 | * | 
| 39 | - * @param Response $response | |
| 39 | + * @param ResponseInterface $response | |
| 40 | 40 | * @param array $data | 
| 41 | 41 | * @param int $status | 
| 42 | 42 | * | 
| @@ -45,7 +45,7 @@ discard block | ||
| 45 | 45 | public function render(ResponseInterface $response, array $data = [], $status = 200) | 
| 46 | 46 |      { | 
| 47 | 47 | $icalendar = new VCalendar(); | 
| 48 | -        if (! isset($data['cfps'])) { | |
| 48 | +        if (!isset($data['cfps'])) { | |
| 49 | 49 | $data['cfps'] = []; | 
| 50 | 50 | } | 
| 51 | 51 |          foreach ($data['cfps'] as $cfp) { | 
| @@ -66,7 +66,7 @@ discard block | ||
| 66 | 66 | 'DTSTAMP' => $lastChange, | 
| 67 | 67 | 'UID' => $cfp['_rel']['cfp_uri'], | 
| 68 | 68 | 'DESCRIPTION' => $cfp['description'], | 
| 69 | - 'GEO' => round($cfp['latitude'], 6) . ';' . round($cfp['longitude'], 6), | |
| 69 | + 'GEO' => round($cfp['latitude'], 6).';'.round($cfp['longitude'], 6), | |
| 70 | 70 | 'LOCATION' => $cfp['location'], | 
| 71 | 71 | |
| 72 | 72 | ]); | 
| @@ -27,22 +27,22 @@ | ||
| 27 | 27 | * @since 15.01.2016 | 
| 28 | 28 | * @link http://github.com/heiglandreas/callingallpapers | 
| 29 | 29 | */ | 
| 30 | -require_once realpath(__DIR__ . '/../vendor/autoload.php'); | |
| 30 | +require_once realpath(__DIR__.'/../vendor/autoload.php'); | |
| 31 | 31 | |
| 32 | 32 | session_start(); | 
| 33 | 33 | |
| 34 | 34 | // Instantiate the app | 
| 35 | -$settings = require __DIR__ . '/../config/settings.php'; | |
| 35 | +$settings = require __DIR__.'/../config/settings.php'; | |
| 36 | 36 | $app = new \Slim\App($settings); | 
| 37 | 37 | |
| 38 | 38 | // Set up dependencies | 
| 39 | -require __DIR__ . '/../config/dependencies.php'; | |
| 39 | +require __DIR__.'/../config/dependencies.php'; | |
| 40 | 40 | |
| 41 | 41 | // Register middleware | 
| 42 | -require __DIR__ . '/../config/middleware.php'; | |
| 42 | +require __DIR__.'/../config/middleware.php'; | |
| 43 | 43 | |
| 44 | 44 | // Register routes | 
| 45 | -require __DIR__ . '/../config/routes.php'; | |
| 45 | +require __DIR__.'/../config/routes.php'; | |
| 46 | 46 | |
| 47 | 47 | // Run app | 
| 48 | 48 | $app->run(); | 
| @@ -51,7 +51,7 @@ | ||
| 51 | 51 | callable $next | 
| 52 | 52 |      ) { | 
| 53 | 53 | $query = $request->getQueryParams(); | 
| 54 | -        if (! isset($query['type'])) { | |
| 54 | +        if (!isset($query['type'])) { | |
| 55 | 55 | return $next($request, $response); | 
| 56 | 56 | } | 
| 57 | 57 | |
| @@ -70,7 +70,7 @@ discard block | ||
| 70 | 70 |          if ($cfp->getDateCfpStart()->getTimestamp() < 10000) { | 
| 71 | 71 | $cfp->setDateCfpStart(new \DateTimeImmutable()); | 
| 72 | 72 | } | 
| 73 | - $statement = 'INSERT into `cfp`(`dateCfpStart`, `dateCfpEnd`, `dateEventStart`, `dateEventEnd`, `name`, `uri`, `hash`, `timezone`, `description`, `eventUri`, `iconUri`, `latitude`, `longitude`, `location`, `tags`, `lastUpdate`) ' . | |
| 73 | + $statement = 'INSERT into `cfp`(`dateCfpStart`, `dateCfpEnd`, `dateEventStart`, `dateEventEnd`, `name`, `uri`, `hash`, `timezone`, `description`, `eventUri`, `iconUri`, `latitude`, `longitude`, `location`, `tags`, `lastUpdate`) '. | |
| 74 | 74 | 'VALUES (:dateCfpStart, :dateCfpEnd, :dateEventStart, :dateEventEnd, :name, :uri, :hash, :timezone, :description, :eventUri, :iconUri, :latitude, :longitude, :location, :tags, :lastUpdate);'; | 
| 75 | 75 | $statement = $this->pdo->prepare($statement); | 
| 76 | 76 | |
| @@ -102,7 +102,7 @@ discard block | ||
| 102 | 102 | |
| 103 | 103 | public function update(Cfp $cfp, $fetchHash) | 
| 104 | 104 |      { | 
| 105 | -        if (! $fetchHash) { | |
| 105 | +        if (!$fetchHash) { | |
| 106 | 106 |              throw new \UnexpectedValueException('No Hash given', 400); | 
| 107 | 107 | } | 
| 108 | 108 | $oldValues = $this->select($fetchHash); | 
| @@ -132,17 +132,17 @@ discard block | ||
| 132 | 132 | ]; | 
| 133 | 133 | |
| 134 | 134 |          foreach ($options as $option) { | 
| 135 | - $method = 'get' . $option; | |
| 135 | + $method = 'get'.$option; | |
| 136 | 136 | // Merge values from tags and source before comparing! | 
| 137 | 137 |              if (in_array($option, ['tags', 'source'])) { | 
| 138 | - $setter = 'set' . $option; | |
| 138 | + $setter = 'set'.$option; | |
| 139 | 139 | $cfp->$setter(array_merge($oldValues->$method(), $cfp->$method())); | 
| 140 | 140 | } | 
| 141 | 141 |              if ($cfp->$method() !== $oldValues->$method()) { | 
| 142 | 142 |                  if ($option == 'dateCfpStart' && $cfp->$method()->getTimestamp() < 100000) { | 
| 143 | 143 | continue; | 
| 144 | 144 | } | 
| 145 | - $statementElements[] = '`' . $option . '` = :' . $option; | |
| 145 | + $statementElements[] = '`'.$option.'` = :'.$option; | |
| 146 | 146 | $values[$option] = $cfp->$method(); | 
| 147 | 147 |                  if ($values[$option] instanceof \DateTimeInterface) { | 
| 148 | 148 |                      $values[$option] = $values[$option]->format('c'); | 
| @@ -162,7 +162,7 @@ discard block | ||
| 162 | 162 | } | 
| 163 | 163 | |
| 164 | 164 | $statement = 'UPDATE `cfp` SET ' | 
| 165 | -                   . implode(',', $statementElements) . ',' | |
| 165 | +                   . implode(',', $statementElements).',' | |
| 166 | 166 | . '`lastUpdate` = :lastUpdate ' | 
| 167 | 167 | . 'WHERE `hash` = :fetchHash'; | 
| 168 | 168 | $statement = $this->pdo->prepare($statement); | 
| @@ -298,10 +298,10 @@ discard block | ||
| 298 | 298 | $values = []; | 
| 299 | 299 | $where = []; | 
| 300 | 300 |          foreach ($parameters as $key => $value) { | 
| 301 | -            if (! in_array($key, $fields)) { | |
| 301 | +            if (!in_array($key, $fields)) { | |
| 302 | 302 | continue; | 
| 303 | 303 | } | 
| 304 | -            if (! is_array($value)) { | |
| 304 | +            if (!is_array($value)) { | |
| 305 | 305 | $value = [$value]; | 
| 306 | 306 | } | 
| 307 | 307 |              foreach ($value as $itemkey => $item) { | 
| @@ -312,22 +312,22 @@ discard block | ||
| 312 | 312 | 'date_event_end', | 
| 313 | 313 | 'date_event_start' | 
| 314 | 314 |                  ])) { | 
| 315 | -                    if (array_key_exists($key . '_compare', $parameters) && isset($parameters[$key . '_compare'][$itemkey]) && in_array($parameters[$key . '_compare'][$itemkey], ['=', '<', '>', '<>'])) { | |
| 316 | - $compare = $parameters[$key . '_compare'][$itemkey]; | |
| 315 | +                    if (array_key_exists($key.'_compare', $parameters) && isset($parameters[$key.'_compare'][$itemkey]) && in_array($parameters[$key.'_compare'][$itemkey], ['=', '<', '>', '<>'])) { | |
| 316 | + $compare = $parameters[$key.'_compare'][$itemkey]; | |
| 317 | 317 | } | 
| 318 | - $where[] = $this->timezoneHelper->getUtcDateTime($transformer->transform($key)) . ' ' . $compare . ' :' . $key . '_' . $itemkey; | |
| 318 | + $where[] = $this->timezoneHelper->getUtcDateTime($transformer->transform($key)).' '.$compare.' :'.$key.'_'.$itemkey; | |
| 319 | 319 |                      $value = (new DateTime($item))->setTimezone(new \DateTimeZone('UTC'))->format('c'); | 
| 320 | 320 |                  } else { | 
| 321 | - $where[] = '`' . $transformer->transform($key) . '` ' . $compare . ' :' . $key; | |
| 321 | + $where[] = '`'.$transformer->transform($key).'` '.$compare.' :'.$key; | |
| 322 | 322 | } | 
| 323 | - $values[$key . '_' . $itemkey] = $value; | |
| 323 | + $values[$key.'_'.$itemkey] = $value; | |
| 324 | 324 | } | 
| 325 | 325 | } | 
| 326 | -        if (! $where) { | |
| 326 | +        if (!$where) { | |
| 327 | 327 |              throw new \UnexpectedValueException('No CFPs found', 404); | 
| 328 | 328 | } | 
| 329 | 329 | |
| 330 | -        $statement .= implode(' AND ', $where) . ' ORDER BY dateCfpEnd ASC'; | |
| 330 | +        $statement .= implode(' AND ', $where).' ORDER BY dateCfpEnd ASC'; | |
| 331 | 331 | |
| 332 | 332 | $statement = $this->pdo->prepare($statement); | 
| 333 | 333 | |
| @@ -53,7 +53,7 @@ | ||
| 53 | 53 | 'sources' => array_values(array_filter(array_unique($cfp->getSource()))), | 
| 54 | 54 |                  'lastChange'     => $cfp->getLastUdated()->format('c'), | 
| 55 | 55 | '_rel' => [ | 
| 56 | - 'cfp_uri' => 'v1/cfp/' . $cfp->getHash(), | |
| 56 | + 'cfp_uri' => 'v1/cfp/'.$cfp->getHash(), | |
| 57 | 57 | ] | 
| 58 | 58 | ]; | 
| 59 | 59 | |