Function getAvailableSites
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function getAvailableSites()
{
$sites = array();
$token = $this->tokenStorage->getToken();
if ($token instanceof TokenInterface) {
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method __construct
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Session $session,
TokenStorageInterface $tokenStorage,
$defaultLocale,
SiteRepositoryInterface $siteRepository,
AuthorizationCheckerInterface $authorizationChecker
- Create a ticketCreate a ticket
Function getBackOfficeLanguage
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function getBackOfficeLanguage()
{
$currentLanguage = $this->session->get(self::KEY_LOCALE);
if (!$currentLanguage) {
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid assigning values to variables in if clauses and the like (line '90', column '18'). Open
public function getAvailableSites()
{
$sites = array();
$token = $this->tokenStorage->getToken();
if ($token instanceof TokenInterface) {
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Avoid assigning values to variables in if clauses and the like (line '64', column '28'). Open
public function getBackOfficeLanguage()
{
$currentLanguage = $this->session->get(self::KEY_LOCALE);
if (!$currentLanguage) {
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Avoid assigning values to variables in if clauses and the like (line '169', column '18'). Open
public function getSiteContributionLanguage()
{
$currentLanguage = $this->getSite()['defaultLanguage'];
$token = $this->tokenStorage->getToken();
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Call to method remove
from undeclared class \Symfony\Component\HttpFoundation\Session\Session
Open
$this->session->remove(self::KEY_LOCALE);
- Create a ticketCreate a ticket
- Exclude checks
Checking instanceof against undeclared class \FOS\UserBundle\Model\GroupableInterface
Open
if (($user = $token->getUser()) instanceof GroupableInterface) {
- Create a ticketCreate a ticket
- Exclude checks
Call to method set
from undeclared class \Symfony\Component\HttpFoundation\Session\Session
Open
$this->session->set(self::KEY_LOCALE, $language);
- Create a ticketCreate a ticket
- Exclude checks
Parameter $tokenStorage
has undeclared type \Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface
Open
public function __construct(
- Create a ticketCreate a ticket
- Exclude checks
Call to method getToken
from undeclared class \Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface
Open
$token = $this->tokenStorage->getToken();
- Create a ticketCreate a ticket
- Exclude checks
Call to method remove
from undeclared class \Symfony\Component\HttpFoundation\Session\Session
Open
$this->session->remove(self::KEY_SITE);
- Create a ticketCreate a ticket
- Exclude checks
Call to method getToken
from undeclared class \Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface
Open
$this->tokenStorage->getToken()->setAuthenticated(false);
- Create a ticketCreate a ticket
- Exclude checks
Call to method get
from undeclared class \Symfony\Component\HttpFoundation\Session\Session
Open
$currentSite = $this->session->get(self::KEY_SITE);
- Create a ticketCreate a ticket
- Exclude checks
Call to method getToken
from undeclared class \Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface
Open
$token = $this->tokenStorage->getToken();
- Create a ticketCreate a ticket
- Exclude checks
Call to method getSiteId
from undeclared class \OpenOrchestra\ModelInterface\Model\SiteInterface
Open
$siteId = $site->getSiteId();
- Create a ticketCreate a ticket
- Exclude checks
Return type of getAvailableSites()
is undeclared type \OpenOrchestra\ModelInterface\Model\SiteInterface[]
Open
public function getAvailableSites()
- Create a ticketCreate a ticket
- Exclude checks
Call to method getUser
from undeclared class \Symfony\Component\Security\Core\Authentication\Token\TokenInterface
Open
if (($user = $token->getUser()) instanceof GroupableInterface) {
- Create a ticketCreate a ticket
- Exclude checks
Call to method getName
from undeclared class \OpenOrchestra\ModelInterface\Model\SiteInterface
Open
$siteName = $site->getName();
- Create a ticketCreate a ticket
- Exclude checks
Call to method set
from undeclared class \Symfony\Component\HttpFoundation\Session\Session
Open
$this->session->set(
- Create a ticketCreate a ticket
- Exclude checks
Call to method getDefaultLanguage
from undeclared class \OpenOrchestra\ModelInterface\Model\SiteInterface
Open
$locale = $site->getDefaultLanguage();
- Create a ticketCreate a ticket
- Exclude checks
Call to method getLanguages
from undeclared class \OpenOrchestra\ModelInterface\Model\SiteInterface
Open
$languages = $site->getLanguages();
- Create a ticketCreate a ticket
- Exclude checks
Parameter $authorizationChecker
has undeclared type \Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface
Open
public function __construct(
- Create a ticketCreate a ticket
- Exclude checks
Call to method get
from undeclared class \Symfony\Component\HttpFoundation\Session\Session
Open
$currentLanguage = $this->session->get(self::KEY_LOCALE);
- Create a ticketCreate a ticket
- Exclude checks
Parameter $siteRepository
has undeclared type \OpenOrchestra\ModelInterface\Repository\SiteRepositoryInterface
Open
public function __construct(
- Create a ticketCreate a ticket
- Exclude checks
Call to method findByDeleted
from undeclared class \OpenOrchestra\ModelInterface\Repository\SiteRepositoryInterface
Open
return $this->siteRepository->findByDeleted(false);
- Create a ticketCreate a ticket
- Exclude checks
Call to method get
from undeclared class \Symfony\Component\HttpFoundation\Session\Session
Open
$currentSite = $this->session->get(self::KEY_SITE);
- Create a ticketCreate a ticket
- Exclude checks
Checking instanceof against undeclared class \Symfony\Component\Security\Core\Authentication\Token\TokenInterface
Open
if ($token instanceof TokenInterface) {
- Create a ticketCreate a ticket
- Exclude checks
Call to method isGranted
from undeclared class \Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface
Open
if ($this->authorizationChecker->isGranted(ContributionRoleInterface::PLATFORM_ADMIN)) {
- Create a ticketCreate a ticket
- Exclude checks
Checking instanceof against undeclared class \Symfony\Component\Security\Core\Authentication\Token\TokenInterface
Open
if ($token instanceof TokenInterface) {
- Create a ticketCreate a ticket
- Exclude checks
Checking instanceof against undeclared class \OpenOrchestra\UserBundle\Model\UserInterface
Open
if ($token && ($user = $token->getUser()) instanceof UserInterface) {
- Create a ticketCreate a ticket
- Exclude checks
Call to method getToken
from undeclared class \Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface
Open
$token = $this->tokenStorage->getToken();
- Create a ticketCreate a ticket
- Exclude checks
Checking instanceof against undeclared class \OpenOrchestra\UserBundle\Model\UserInterface
Open
if (($user = $token->getUser()) instanceof UserInterface && $user->hasLanguageBySite($this->getSiteId())) {
- Create a ticketCreate a ticket
- Exclude checks
Call to method getUser
from undeclared class \Symfony\Component\Security\Core\Authentication\Token\TokenInterface
Open
if (($user = $token->getUser()) instanceof UserInterface && $user->hasLanguageBySite($this->getSiteId())) {
- Create a ticketCreate a ticket
- Exclude checks
Parameter $session
has undeclared type \Symfony\Component\HttpFoundation\Session\Session
Open
public function __construct(
- Create a ticketCreate a ticket
- Exclude checks
Declaration of function getAvailableSites() : \OpenOrchestra\ModelInterface\Model\SiteInterface[]
should be compatible with function getAvailableSites() : \OpenOrchestra\Backoffice\Context\SiteInterface[]
defined in /code/Backoffice/Context/ContextBackOfficeInterface.php:26
Open
public function getAvailableSites()
- Create a ticketCreate a ticket
- Exclude checks
Function closing brace must go on the next line following the body; found 1 blank lines before brace Open
}
- Create a ticketCreate a ticket
- Exclude checks