IndexController::DraftOptions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 9
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace PhpDraft\Controllers;
4
5
use \Silex\Application;
6
use Symfony\Component\HttpFoundation\Response;
7
use PhpDraft\Domain\Models\PhpDraftResponse;
8
9
class IndexController
10
{
11
  public function Style(Application $app) {
12
    $colors = $app['phpdraft.DraftDataRepository']->GetPositionColors();
13
14
    $minified_css = '';
15
16
    foreach ($colors as $position => $hex_color_key) {
17
      $minified_css .= "div.pick$position{background-color:$hex_color_key;}";
18
    }
19
20
    return new Response($minified_css, 200, array(
21
        "Content-Type" => "text/css"
22
    ));
23
  }
24
25
  public function DraftOptions(Application $app) {
26
    $sports = $app['phpdraft.DraftDataRepository']->GetSports();
27
    $statuses = $app['phpdraft.DraftDataRepository']->GetStatuses();
28
29
    $response = new PhpDraftResponse(true);
30
    $response->sports = $sports;
0 ignored issues
show
Bug introduced by
The property sports does not seem to exist on PhpDraft\Domain\Models\PhpDraftResponse.
Loading history...
31
    $response->statuses = $statuses;
0 ignored issues
show
Bug introduced by
The property statuses does not seem to exist on PhpDraft\Domain\Models\PhpDraftResponse.
Loading history...
32
33
    return $app->json($response, $response->responseType());
34
  }
35
}
36