ProPlayerController::Search()   A
last analyzed

Complexity

Conditions 6
Paths 32

Size

Total Lines 24
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 24
rs 9.1111
c 0
b 0
f 0
cc 6
nc 32
nop 2
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
}