ManagerController   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 13
dl 0
loc 25
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A GetAll() 0 4 1
A GetManagerDepthChart() 0 18 4
1
<?php
2
namespace PhpDraft\Controllers;
3
4
use Silex\Application;
5
use Symfony\Component\HttpFoundation\Request;
6
use PhpDraft\Domain\Entities\Manager;
7
use PhpDraft\Domain\Models\PhpDraftResponse;
8
9
class ManagerController {
10
  public function GetAll(Application $app, Request $request) {
11
    $draft_id = (int)$request->get('draft_id');
12
13
    return $app->json($app['phpdraft.ManagerRepository']->GetPublicManagers($draft_id));
14
  }
15
16
  public function GetManagerDepthChart(Application $app, Request $request) {
17
    $draft_id = (int)$request->get('draft_id');
18
    $manager_id = (int)$request->get('manager_id');
19
20
    if (empty($draft_id) || $draft_id == 0) {
21
      throw new \Exception("Unable to load draft.");
22
    }
23
24
    $draft = $app['phpdraft.DraftRepository']->Load($draft_id);
25
26
    if (!$draft->using_depth_charts) {
27
      $response = $app['phpdraft.ResponseFactory'](false, array("Draft is not configured to use depth charts."));
28
      return $app->json($response, $response->responseType());
29
    }
30
31
    $response = $app['phpdraft.DepthChartPositionService']->GetManagerDepthChart($draft, $manager_id);
32
33
    return $app->json($response, $response->responseType());
34
  }
35
}