DepthChartPositionController::GetPositions()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 14
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
namespace PhpDraft\Controllers\Commish;
3
4
use \Silex\Application;
5
use Symfony\Component\HttpFoundation\Response;
6
use Symfony\Component\HttpFoundation\Request;
7
use PhpDraft\Domain\Models\PhpDraftResponse;
8
use PhpDraft\Domain\Entities\DepthChartPosition;
9
10
class DepthChartPositionController
11
{
12
  public function GetPositions(Application $app, Request $request) {
13
    $draft_sport = $request->get('draft_sport');
14
15
    $validity = $app['phpdraft.DepthChartPositionValidator']->IsDraftSportValid($draft_sport);
16
17
    if (!$validity->success) {
18
      return $app->json($validity, Response::HTTP_BAD_REQUEST);
19
    }
20
21
    $response = $app['phpdraft.ResponseFactory'](true, array());
22
    $response->positions = array();
23
    $response->positions = $app['phpdraft.DraftDataRepository']->GetPositions($draft_sport);
24
25
    return $app->json($response);
26
  }
27
}