ProPlayerController   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 17
dl 0
loc 25
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A Search() 0 24 6
1
<?php
2
3
namespace PhpDraft\Controllers\Commish;
4
5
use \Silex\Application;
6
use Symfony\Component\HttpFoundation\Request;
7
use Symfony\Component\HttpFoundation\Response;
8
use PhpDraft\Domain\Entities\ProPlayer;
9
use PhpDraft\Domain\Models\PhpDraftResponse;
10
11
class ProPlayerController {
12
  public function Search(Application $app, Request $request) {
13
    $league = $request->get('league');
14
15
    $searchTerm = $request->get('searchTerm');
16
17
    $first = $request->get('first');
18
    $last = $request->get('last');
19
    $team = $request->get('team');
20
    $position = $request->get('position');
21
    
22
    $first = strlen($first) == 0 ? "NA" : $first;
23
    $last = strlen($last) == 0 ? "NA" : $last;
24
    $team = strlen($team) == 0 ? "NA" : $team;
25
    $position = strlen($position) == 0 ? "NA" : $position;
26
27
    $response = new PhpDraftResponse();
0 ignored issues
show
Unused Code introduced by
The assignment to $response is dead and can be removed.
Loading history...
28
29
    if (count($searchTerm) > 0) {
30
      $response = $app['phpdraft.ProPlayerService']->SearchPlayers($league, $searchTerm);
31
    } else {
32
      $response = $app['phpdraft.ProPlayerService']->SearchPlayersManual($league, $first, $last, $team, $position);
33
    }
34
35
    return $app->json($response, $response->responseType());
36
  }
37
}