Version   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 0
dl 0
loc 55
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
canParseRequest() 0 1 ?
parseRequest() 0 1 ?
createResponse() 0 5 ?
tableView() 0 1 ?
scriptView() 0 1 ?
1
<?php
2
3
namespace OpenSkill\Datatable\Versions;
4
5
use OpenSkill\Datatable\Columns\ColumnConfiguration;
6
use OpenSkill\Datatable\Data\ResponseData;
7
use OpenSkill\Datatable\Queries\QueryConfiguration;
8
use Symfony\Component\HttpFoundation\JsonResponse;
9
use Symfony\Component\HttpFoundation\Request;
10
use Symfony\Component\HttpFoundation\RequestStack;
11
12
/**
13
 * Class Version
14
 * @package OpenSkill\Datatable\Versions
15
 *
16
 * Base interface that is used to support different frontend views from this data table plugin
17
 */
18
abstract class Version
19
{
20
    /**
21
     * @var RequestStack
22
     */
23
    protected $requestStack;
24
25
    /**
26
     * Version constructor.
27
     */
28
    public function __construct(RequestStack $requestStack)
29
    {
30
        $this->requestStack = $requestStack;
31
    }
32
33
    /**
34
     * Method to determine if this parser can handle the query parameters. If so then the parser should return true
35
     * and be able to return a DTQueryConfiguration
36
     *
37
     * @return bool true if the parser is able to parse the query parameters and to return a DTQueryConfiguration
38
     */
39
    abstract public function canParseRequest();
40
41
    /**
42
     * Method that should parse the request and return a DTQueryConfiguration
43
     *
44
     * @param ColumnConfiguration[] $columnConfiguration The configuration of the columns
45
     * @return QueryConfiguration the configuration the provider can use to prepare the data
46
     */
47
    abstract public function parseRequest(array $columnConfiguration);
48
49
50
    /**
51
     * Is responsible to take the generated data and prepare a response for it.
52
     * @param ResponseData $data The processed data.
53
     * @param QueryConfiguration $queryConfiguration the query configuration for the current request.
54
     * @param ColumnConfiguration[] $columnConfigurations the column configurations for the current data table.
55
     * @return JsonResponse the response that should be returned to the client.
56
     */
57
    abstract public function createResponse(
58
        ResponseData $data,
59
        QueryConfiguration $queryConfiguration,
60
        array $columnConfigurations
61
    );
62
63
    /**
64
     * @return string The name of the view that this version should use fot the table.
65
     */
66
    abstract public function tableView();
67
68
    /**
69
     * @return string The name of the view that this version should use for the script.
70
     */
71
    abstract public function scriptView();
72
}