Passed
Push — master ( 8d3590...a319dd )
by Angel Fernando Quiroz
17:46 queued 08:38
created

SchemaItemController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 17
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 12 2
1
<?php
2
3
/* For licensing terms,
4
see /license.txt */
5
6
declare(strict_types=1);
7
8
namespace Chamilo\CoreBundle\Controller\Scim;
9
10
use Chamilo\CoreBundle\Exception\ScimException;
11
use Chamilo\CoreBundle\Traits\Scim\UserSchemaControllerTrait;
12
use Symfony\Component\HttpFoundation\JsonResponse;
13
use Symfony\Component\HttpFoundation\Response;
14
use Symfony\Component\Routing\Attribute\Route;
15
16
#[Route('/scim/v2/Schemas/{schemaId}', name: 'scim_schema', methods: ['GET'])]
17
class SchemaItemController extends AbstractScimController
18
{
19
    use UserSchemaControllerTrait;
20
21
    public function __invoke(string $schemaId): JsonResponse
22
    {
23
        if ('urn:ietf:params:scim:schemas:core:2.0:User' !== $schemaId) {
24
            throw new ScimException($this->translator->trans('Schema not supported'));
25
        }
26
27
        $userSchema = $this->getUserCoreSchema();
28
29
        return new JsonResponse(
30
            $userSchema,
31
            Response::HTTP_OK,
32
            ['Content-Type' => self::SCIM_CONTENT_TYPE]
33
        );
34
    }
35
}
36