Code Duplication    Length = 23-24 lines in 2 locations

src/AppBundle/Controller/ApiController.php 2 locations

@@ 34-56 (lines=23) @@
31
     * @param string $project Project database name, URL, or domain name.
32
     * @return View
33
     */
34
    public function normalizeProject($project)
35
    {
36
        $proj = ProjectRepository::getProject($project, $this->container);
37
38
        if (!$proj->exists()) {
39
            return new View(
40
                [
41
                    'error' => "$project is not a valid project",
42
                ],
43
                Response::HTTP_NOT_FOUND
44
            );
45
        }
46
47
        return new View(
48
            [
49
                'domain' => $proj->getDomain(),
50
                'url' => $proj->getUrl(),
51
                'api' => $proj->getApiUrl(),
52
                'database' => $proj->getDatabaseName(),
53
            ],
54
            Response::HTTP_OK
55
        );
56
    }
57
58
    /**
59
     * Get all namespaces of the given project. This endpoint also does the same thing
@@ 65-88 (lines=24) @@
62
     * @param string $project The project name.
63
     * @return View
64
     */
65
    public function namespaces($project)
66
    {
67
        $proj = ProjectRepository::getProject($project, $this->container);
68
69
        if (!$proj->exists()) {
70
            return new View(
71
                [
72
                    'error' => "$project is not a valid project",
73
                ],
74
                Response::HTTP_NOT_FOUND
75
            );
76
        }
77
78
        return new View(
79
            [
80
                'domain' => $proj->getDomain(),
81
                'url' => $proj->getUrl(),
82
                'api' => $proj->getApiUrl(),
83
                'database' => $proj->getDatabaseName(),
84
                'namespaces' => $proj->getNamespaces(),
85
            ],
86
            Response::HTTP_OK
87
        );
88
    }
89
}
90