Code Duplication    Length = 50-50 lines in 2 locations

src/OpenSkill/Datatable/Versions/Datatable110Version.php 1 location

@@ 21-70 (lines=50) @@
18
 * http://datatables.net/index
19
 *
20
 */
21
class Datatable110Version extends DatatableVersion
22
{
23
    /**
24
     * Datatable110Version constructor.
25
     *
26
     * @param RequestStack $requestStack The current request
27
     */
28
    public function __construct(RequestStack $requestStack)
29
    {
30
        parent::__construct($requestStack, new Datatable110QueryParser());
31
    }
32
33
    /**
34
     * Is responsible to take the generated data and prepare a response for it.
35
     * @param ResponseData $data The processed data.
36
     * @param QueryConfiguration $queryConfiguration the query configuration for the current request.
37
     * @param ColumnConfiguration[] $columnConfigurations the column configurations for the current data table.
38
     * @return JsonResponse the response that should be returned to the client.
39
     */
40
    public function createResponse(
41
        ResponseData $data,
42
        QueryConfiguration $queryConfiguration,
43
        array $columnConfigurations
44
    ) {
45
        $responseData = [
46
            'draw' => $queryConfiguration->drawCall(),
47
            'recordsTotal' => $data->totalDataCount(),
48
            'recordsFiltered' => $data->filteredDataCount(),
49
            'data' => $data->data()->toArray()
50
        ];
51
52
        return new JsonResponse($responseData);
53
    }
54
55
    /**
56
     * @return string The name of the view that this version should use fot the table.
57
     */
58
    public function tableView()
59
    {
60
        return "datatable::table";
61
    }
62
63
    /**
64
     * @return string The name of the view that this version should use for the script.
65
     */
66
    public function scriptView()
67
    {
68
        return "datatable::datatable110";
69
    }
70
}

src/OpenSkill/Datatable/Versions/Datatable19Version.php 1 location

@@ 22-71 (lines=50) @@
19
 * http://legacy.datatables.net/index
20
 *
21
 */
22
class Datatable19Version extends DatatableVersion
23
{
24
    /**
25
     * Datatable19Version constructor.
26
     *
27
     * @param RequestStack $requestStack The current request
28
     */
29
    public function __construct(RequestStack $requestStack)
30
    {
31
        parent::__construct($requestStack, new Datatable19QueryParser());
32
    }
33
34
    /**
35
     * Is responsible to take the generated data and prepare a response for it.
36
     * @param ResponseData $data The processed data.
37
     * @param QueryConfiguration $queryConfiguration the query configuration for the current request.
38
     * @param ColumnConfiguration[] $columnConfigurations the column configurations for the current data table.
39
     * @return JsonResponse the response that should be returned to the client.
40
     */
41
    public function createResponse(
42
        ResponseData $data,
43
        QueryConfiguration $queryConfiguration,
44
        array $columnConfigurations
45
    ) {
46
        $responseData = [
47
            'sEcho' => $queryConfiguration->drawCall(),
48
            'iTotalRecords' => $data->totalDataCount(),
49
            'iTotalDisplayRecords' => $data->filteredDataCount(),
50
            'aaData' => $data->data()->toArray()
51
        ];
52
53
        return new JsonResponse($responseData);
54
    }
55
56
    /**
57
     * @return string The name of the view that this version should use fot the table.
58
     */
59
    public function tableView()
60
    {
61
        return "datatable::table";
62
    }
63
64
    /**
65
     * @return string The name of the view that this version should use for the script.
66
     */
67
    public function scriptView()
68
    {
69
        return "datatable::datatable19";
70
    }
71
}
72