open-orchestra/open-orchestra-cms-bundle

View on GitHub
UserAdminBundle/Controller/Api/UserController.php

Summary

Maintainability
A
0 mins
Test Coverage

Avoid using static access to class '\OpenOrchestra\Pagination\Configuration\PaginateFinderConfiguration' in method 'listInGroupAction'.
Open

        $configuration = PaginateFinderConfiguration::generateFromRequest($request, $mapping);

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\OpenOrchestra\Pagination\Configuration\PaginateFinderConfiguration' in method 'listAction'.
Open

        $configuration = PaginateFinderConfiguration::generateFromRequest($request, $mapping);

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

The method listAction uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $sitesId = $this->getAvailableSiteIds();
            $collection = $repository->findForPaginateFilterBySiteIds($configuration, $language, $sitesId);
            $recordsTotal = $repository->countFilterBySiteIds($sitesId);
            $recordsFiltered = $repository->countWithFilterAndSiteIds($configuration, $language, $sitesId);

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

Possibly zero references to use statement for classlike/namespace Api (\OpenOrchestra\BaseApiBundle\Controller\Annotation)
Open

use OpenOrchestra\BaseApiBundle\Controller\Annotation as Api;

Returning type array{} but showAction() is declared to return \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open

        return array();

Class extends undeclared class \OpenOrchestra\BaseApiBundle\Controller\BaseController
Open

class UserController extends BaseController

Call to undeclared method \OpenOrchestra\UserAdminBundle\Controller\Api\UserController::get
Open

            return $this->get('open_orchestra_api.transformer_manager')->transform('user', $user);

Parameter $request has undeclared type \Symfony\Component\HttpFoundation\Request
Open

    public function removeGroupAction(Request $request, $groupId)

Call to undeclared method \OpenOrchestra\UserAdminBundle\Controller\Api\UserController::get
Open

        $availableSites = $this->get('open_orchestra_backoffice.context_backoffice_manager')->getAvailableSites();

Possibly zero references to use statement for classlike/namespace Config (\Sensio\Bundle\FrameworkExtraBundle\Configuration)
Open

use Sensio\Bundle\FrameworkExtraBundle\Configuration as Config;

Return type of addGroupAction() is undeclared type \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open

    public function addGroupAction(Request $request, $groupId)

@throws type of addGroupAction has undeclared type \OpenOrchestra\BaseApi\Exceptions\HttpException\UserNotFoundHttpException
Open

    public function addGroupAction(Request $request, $groupId)

Call to undeclared method \OpenOrchestra\UserAdminBundle\Controller\Api\UserController::get
Open

        $group =  $this->get('open_orchestra_user.repository.group')->find($groupId);

Call to undeclared method \OpenOrchestra\UserAdminBundle\Controller\Api\UserController::get
Open

        $this->get('open_orchestra_user.repository.user')->addGroup($users, $group);

Call to undeclared method \OpenOrchestra\UserAdminBundle\Controller\Api\UserController::get
Open

        $users = $this->get('open_orchestra_api.transformer_manager')->reverseTransform('user_collection', $facade);

Reference to constant USER_DELETE from undeclared class \OpenOrchestra\UserBundle\UserEvents
Open

                $this->dispatchEvent(UserEvents::USER_DELETE, new UserEvent($user));

Call to method generateFromRequest from undeclared class \OpenOrchestra\Pagination\Configuration\PaginateFinderConfiguration
Open

        $configuration = PaginateFinderConfiguration::generateFromRequest($request, $mapping);

Call to undeclared method \OpenOrchestra\UserAdminBundle\Controller\Api\UserController::isGranted
Open

            if ($this->isGranted(ContributionActionInterface::DELETE, $user)) {

Checking instanceof against undeclared class \OpenOrchestra\UserBundle\Model\UserInterface
Open

        if ($user instanceof UserInterface) {

Call to method generateFromRequest from undeclared class \OpenOrchestra\Pagination\Configuration\PaginateFinderConfiguration
Open

        $configuration = PaginateFinderConfiguration::generateFromRequest($request, $mapping);

Call to undeclared method \OpenOrchestra\UserAdminBundle\Controller\Api\UserController::getParameter
Open

            $this->getParameter('open_orchestra_user_admin.facade.user_collection.class'),

Reference to constant ENTITY_TYPE from undeclared class \OpenOrchestra\UserBundle\Model\UserInterface
Open

        $this->denyAccessUnlessGranted(ContributionActionInterface::READ, UserInterface::ENTITY_TYPE);

Return type of listAction() is undeclared type \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open

    public function listAction(Request $request)

Call to undeclared method \OpenOrchestra\UserAdminBundle\Controller\Api\UserController::get
Open

        $facade = $this->get('open_orchestra_api.transformer_manager')->transform('user_collection', $collection);

Returning type array{} but addGroupAction() is declared to return \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open

        return array();

Parameter $request has undeclared type \Symfony\Component\HttpFoundation\Request
Open

    public function deleteUsersAction(Request $request)

Call to method get from undeclared class \Symfony\Component\HttpFoundation\Request
Open

        $format = $request->get('_format', 'json');

Call to method getId from undeclared class \OpenOrchestra\UserBundle\Model\UserInterface
Open

        $this->get('open_orchestra_user.repository.user')->removeGroup($user->getId(), $groupId);

Parameter $request has undeclared type \Symfony\Component\HttpFoundation\Request
Open

    public function addGroupAction(Request $request, $groupId)

Call to undeclared method \OpenOrchestra\UserAdminBundle\Controller\Api\UserController::get
Open

        $users = $this->get('open_orchestra_api.transformer_manager')->get('user_collection')->reverseTransform($facade);

Call to undeclared method \OpenOrchestra\UserAdminBundle\Controller\Api\UserController::get
Open

        $facade = $this->get('jms_serializer')->deserialize(

Call to undeclared method \OpenOrchestra\UserAdminBundle\Controller\Api\UserController::get
Open

        $userRepository = $this->get('open_orchestra_user.repository.user');

Returning type array{} but deleteUsersAction() is declared to return \Symfony\Component\HttpFoundation\Response
Open

        return array();

Call to undeclared method \OpenOrchestra\UserAdminBundle\Controller\Api\UserController::get
Open

        $repository = $this->get('open_orchestra_user.repository.user');

Call to undeclared method \OpenOrchestra\UserAdminBundle\Controller\Api\UserController::get
Open

        $facade = $this->get('jms_serializer')->deserialize(

Call to undeclared method \OpenOrchestra\UserAdminBundle\Controller\Api\UserController::get
Open

        $repository = $this->get('open_orchestra_user.repository.user');

Call to undeclared method \OpenOrchestra\UserAdminBundle\Controller\Api\UserController::get
Open

        $user = $this->get('open_orchestra_api.transformer_manager')->reverseTransform('user', $facade);

Call to undeclared method \OpenOrchestra\UserAdminBundle\Controller\Api\UserController::get
Open

        $language = $this->get('open_orchestra_backoffice.context_backoffice_manager')->getBackOfficeLanguage();

Call to method __construct from undeclared class \OpenOrchestra\BaseApi\Exceptions\HttpException\UserNotFoundHttpException
Open

            throw new UserNotFoundHttpException();

Call to undeclared method \OpenOrchestra\UserAdminBundle\Controller\Api\UserController::dispatchEvent
Open

                $this->dispatchEvent(UserEvents::USER_DELETE, new UserEvent($user));

Call to method get from undeclared class \Symfony\Component\HttpFoundation\Request
Open

        $format = $request->get('_format', 'json');

Return type of showAction() is undeclared type \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open

    public function showAction($email)

Call to undeclared method \OpenOrchestra\UserAdminBundle\Controller\Api\UserController::denyAccessUnlessGranted
Open

        $this->denyAccessUnlessGranted(ContributionActionInterface::READ, UserInterface::ENTITY_TYPE);

Checking instanceof against undeclared class \OpenOrchestra\UserBundle\Model\UserInterface
Open

        if (!$user instanceof UserInterface) {

Call to undeclared method \OpenOrchestra\UserAdminBundle\Controller\Api\UserController::get
Open

        $facade = $this->get('jms_serializer')->deserialize(

Call to method getContent from undeclared class \Symfony\Component\HttpFoundation\Request
Open

            $request->getContent(),

Call to undeclared method \OpenOrchestra\UserAdminBundle\Controller\Api\UserController::getParameter
Open

            $this->getParameter('open_orchestra_user_admin.facade.user_collection.class'),

Call to undeclared method \OpenOrchestra\UserAdminBundle\Controller\Api\UserController::get
Open

        if ($this->get('security.authorization_checker')->isGranted(ContributionRoleInterface::PLATFORM_ADMIN)) {

Parameter $request has undeclared type \Symfony\Component\HttpFoundation\Request
Open

    public function listInGroupAction(Request $request, $groupId)

Return type of removeGroupAction() is undeclared type \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open

    public function removeGroupAction(Request $request, $groupId)

Call to method get from undeclared class \Symfony\Component\HttpFoundation\Request
Open

        $format = $request->get('_format', 'json');

Call to undeclared method \OpenOrchestra\UserAdminBundle\Controller\Api\UserController::denyAccessUnlessGranted
Open

        $this->denyAccessUnlessGranted(ContributionActionInterface::EDIT, $user);

Return type of deleteUsersAction() is undeclared type \Symfony\Component\HttpFoundation\Response
Open

    public function deleteUsersAction(Request $request)

Call to method __construct from undeclared class \OpenOrchestra\UserBundle\Event\UserEvent
Open

                $this->dispatchEvent(UserEvents::USER_DELETE, new UserEvent($user));

Reference to constant ENTITY_TYPE from undeclared class \OpenOrchestra\UserBundle\Model\UserInterface
Open

        $this->denyAccessUnlessGranted(ContributionActionInterface::READ, UserInterface::ENTITY_TYPE);

Return type of listInGroupAction() is undeclared type \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open

    public function listInGroupAction(Request $request, $groupId)

Call to method getContent from undeclared class \Symfony\Component\HttpFoundation\Request
Open

            $request->getContent(),

Call to undeclared method \OpenOrchestra\UserAdminBundle\Controller\Api\UserController::denyAccessUnlessGranted
Open

        $this->denyAccessUnlessGranted(ContributionActionInterface::READ, UserInterface::ENTITY_TYPE);

Call to undeclared method \OpenOrchestra\UserAdminBundle\Controller\Api\UserController::get
Open

        $facade = $this->get('open_orchestra_api.transformer_manager')->transform('user_collection', $collection);

@throws type of removeGroupAction has undeclared type \OpenOrchestra\BaseApi\Exceptions\HttpException\UserNotFoundHttpException
Open

    public function removeGroupAction(Request $request, $groupId)

Call to undeclared method \OpenOrchestra\UserAdminBundle\Controller\Api\UserController::getParameter
Open

            $this->getParameter('open_orchestra_user_admin.facade.user.class'),

Call to undeclared method \OpenOrchestra\UserAdminBundle\Controller\Api\UserController::get
Open

        $this->get('open_orchestra_user.repository.user')->removeGroup($user->getId(), $groupId);

Returning type array{} but removeGroupAction() is declared to return \OpenOrchestra\BaseApi\Facade\FacadeInterface
Open

        return array();

Call to undeclared method \OpenOrchestra\UserAdminBundle\Controller\Api\UserController::get
Open

        $user = $this->get('open_orchestra_user.repository.user')->findOneByEmail($email);

Parameter $request has undeclared type \Symfony\Component\HttpFoundation\Request
Open

    public function listAction(Request $request)

Call to method getContent from undeclared class \Symfony\Component\HttpFoundation\Request
Open

            $request->getContent(),

Line exceeds 120 characters; contains 121 characters
Open

        $users = $this->get('open_orchestra_api.transformer_manager')->get('user_collection')->reverseTransform($facade);

There are no issues that match your filters.

Category
Status