open-orchestra/open-orchestra-cms-bundle

View on GitHub
Backoffice/Manager/ContentManager.php

Summary

Maintainability
A
35 mins
Test Coverage

Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

        StatusRepositoryInterface $statusRepository,
        ContextBackOfficeInterface $contextManager,
        $contentClass,
        UniqueIdGenerator $uniqueIdGenerator,
        TokenStorage $tokenStorage
Severity: Minor
Found in Backoffice/Manager/ContentManager.php - About 35 mins to fix

Missing class import via use statement (line '134', column '21').
Open

        $date = new \DateTime("now");
Severity: Minor
Found in Backoffice/Manager/ContentManager.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

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

        } else {
            $initialStatus = $this->statusRepository->findOneByOutOfWorkflow();
        }
Severity: Minor
Found in Backoffice/Manager/ContentManager.php by phpmd

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

Reference to undeclared property \OpenOrchestra\Backoffice\Manager\ContentManager->uniqueIdGenerator
Open

        $content->setVersion($this->uniqueIdGenerator->generateUniqueId());
Severity: Minor
Found in Backoffice/Manager/ContentManager.php by phan

Call to method getName from undeclared class \OpenOrchestra\ModelInterface\Model\ContentInterface
Open

        $newContent->setName($this->duplicateLabel($content->getName()));
Severity: Critical
Found in Backoffice/Manager/ContentManager.php by phan

Parameter $content has undeclared type \OpenOrchestra\ModelInterface\Model\ContentInterface
Open

    protected function cloneContent(ContentInterface $content)
Severity: Minor
Found in Backoffice/Manager/ContentManager.php by phan

Call to method findOneByInitial from undeclared class \OpenOrchestra\ModelInterface\Repository\StatusRepositoryInterface
Open

            $status = $this->statusRepository->findOneByInitial();
Severity: Critical
Found in Backoffice/Manager/ContentManager.php by phan

Call to method setName from undeclared class \OpenOrchestra\ModelInterface\Model\ContentInterface
Open

        $newContent->setName($this->duplicateLabel($content->getName()));
Severity: Critical
Found in Backoffice/Manager/ContentManager.php by phan

Call to method setVersion from undeclared class \OpenOrchestra\ModelInterface\Model\ContentInterface
Open

        $newContent->setVersion($this->uniqueIdGenerator->generateUniqueId());
Severity: Critical
Found in Backoffice/Manager/ContentManager.php by phan

Return type of initializeNewContent() is undeclared type \OpenOrchestra\ModelInterface\Model\ContentInterface
Open

    public function initializeNewContent($contentType, $language, $isLinkedToSite, $isStatusable)
Severity: Minor
Found in Backoffice/Manager/ContentManager.php by phan

Parameter $node has undeclared type \OpenOrchestra\ModelInterface\Model\ContentInterface
Open

    public function setVersionName(ContentInterface $node)
Severity: Minor
Found in Backoffice/Manager/ContentManager.php by phan

Return type of setVersionName() is undeclared type \OpenOrchestra\ModelInterface\Model\ContentInterface
Open

    public function setVersionName(ContentInterface $node)
Severity: Minor
Found in Backoffice/Manager/ContentManager.php by phan

Return type of cloneContent() is undeclared type \OpenOrchestra\ModelInterface\Model\ContentInterface
Open

    protected function cloneContent(ContentInterface $content)
Severity: Minor
Found in Backoffice/Manager/ContentManager.php by phan

Parameter $tokenStorage has undeclared type \Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage
Open

    public function __construct(
Severity: Minor
Found in Backoffice/Manager/ContentManager.php by phan

Call to method getToken from undeclared class \Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage
Open

        $content->setCreatedBy($this->tokenStorage->getToken()->getUser()->getUsername());
Severity: Critical
Found in Backoffice/Manager/ContentManager.php by phan

Call to method setLanguage from undeclared class \OpenOrchestra\ModelInterface\Model\ContentInterface
Open

        $content->setLanguage($language);
Severity: Critical
Found in Backoffice/Manager/ContentManager.php by phan

Call to method findOneByInitial from undeclared class \OpenOrchestra\ModelInterface\Repository\StatusRepositoryInterface
Open

            $initialStatus = $this->statusRepository->findOneByInitial();
Severity: Critical
Found in Backoffice/Manager/ContentManager.php by phan

Parameter $content has undeclared type \OpenOrchestra\ModelInterface\Model\ContentInterface
Open

    public function duplicateContent(ContentInterface $content, $contentId = null)
Severity: Minor
Found in Backoffice/Manager/ContentManager.php by phan

Call to method getName from undeclared class \OpenOrchestra\ModelInterface\Model\ContentInterface
Open

        $versionName = $node->getName().'_'. $date->format("Y-m-d_H:i:s");
Severity: Critical
Found in Backoffice/Manager/ContentManager.php by phan

Call to method getAttributes from undeclared class \OpenOrchestra\ModelInterface\Model\ContentInterface
Open

        foreach ($content->getAttributes() as $attribute) {
Severity: Critical
Found in Backoffice/Manager/ContentManager.php by phan

Parameter $originalContent has undeclared type \OpenOrchestra\ModelInterface\Model\ContentInterface
Open

    public function newVersionContent(ContentInterface $originalContent, $versionName = '')
Severity: Minor
Found in Backoffice/Manager/ContentManager.php by phan

Call to method addAttribute from undeclared class \OpenOrchestra\ModelInterface\Model\ContentInterface
Open

            $newContent->addAttribute($newAttribute);
Severity: Critical
Found in Backoffice/Manager/ContentManager.php by phan

Reference to undeclared property \OpenOrchestra\Backoffice\Manager\ContentManager->uniqueIdGenerator (Did you mean $uniqueIdGenerator)
Open

        $this->uniqueIdGenerator = $uniqueIdGenerator;
Severity: Minor
Found in Backoffice/Manager/ContentManager.php by phan

Call to method findOneByTranslationState from undeclared class \OpenOrchestra\ModelInterface\Repository\StatusRepositoryInterface
Open

            $translationStatus = $this->statusRepository->findOneByTranslationState();
Severity: Critical
Found in Backoffice/Manager/ContentManager.php by phan

Call to method setStatus from undeclared class \OpenOrchestra\ModelInterface\Model\ContentInterface
Open

            $newContent->setStatus($status);
Severity: Critical
Found in Backoffice/Manager/ContentManager.php by phan

Call to method findOneByOutOfWorkflow from undeclared class \OpenOrchestra\ModelInterface\Repository\StatusRepositoryInterface
Open

            $initialStatus = $this->statusRepository->findOneByOutOfWorkflow();
Severity: Critical
Found in Backoffice/Manager/ContentManager.php by phan

Call to method getStatus from undeclared class \OpenOrchestra\ModelInterface\Model\ContentInterface
Open

        if (false === $content->getStatus()->isOutOfWorkflow()) {
Severity: Critical
Found in Backoffice/Manager/ContentManager.php by phan

Call to method setVersionName from undeclared class \OpenOrchestra\ModelInterface\Model\ContentInterface
Open

        $node->setVersionName($versionName);
Severity: Critical
Found in Backoffice/Manager/ContentManager.php by phan

Call to method setStatus from undeclared class \OpenOrchestra\ModelInterface\Model\ContentInterface
Open

            $content->setStatus($translationStatus);
Severity: Critical
Found in Backoffice/Manager/ContentManager.php by phan

Call to method setContentId from undeclared class \OpenOrchestra\ModelInterface\Model\ContentInterface
Open

        $newContent->setContentId($contentId);
Severity: Critical
Found in Backoffice/Manager/ContentManager.php by phan

Call to method getStatus from undeclared class \OpenOrchestra\ModelInterface\Model\ContentInterface
Open

        if (false === $content->getStatus()->isOutOfWorkflow()) {
Severity: Critical
Found in Backoffice/Manager/ContentManager.php by phan

Reference to undeclared property \OpenOrchestra\Backoffice\Manager\ContentManager->uniqueIdGenerator
Open

        $newContent->setVersion($this->uniqueIdGenerator->generateUniqueId());
Severity: Minor
Found in Backoffice/Manager/ContentManager.php by phan

Call to method addKeyword from undeclared class \OpenOrchestra\ModelInterface\Model\ContentInterface
Open

            $newContent->addKeyword($keyword);
Severity: Critical
Found in Backoffice/Manager/ContentManager.php by phan

Parameter $contentSource has undeclared type \OpenOrchestra\ModelInterface\Model\ContentInterface
Open

    public function createNewLanguageContent($contentSource, $language)
Severity: Minor
Found in Backoffice/Manager/ContentManager.php by phan

Call to method setVersionName from undeclared class \OpenOrchestra\ModelInterface\Model\ContentInterface
Open

        $newContent->setVersionName($versionName);
Severity: Critical
Found in Backoffice/Manager/ContentManager.php by phan

Return type of createNewLanguageContent() is undeclared type \OpenOrchestra\ModelInterface\Model\ContentInterface
Open

    public function createNewLanguageContent($contentSource, $language)
Severity: Minor
Found in Backoffice/Manager/ContentManager.php by phan

Return type of duplicateContent() is undeclared type \OpenOrchestra\ModelInterface\Model\ContentInterface
Open

    public function duplicateContent(ContentInterface $content, $contentId = null)
Severity: Minor
Found in Backoffice/Manager/ContentManager.php by phan

Parameter $statusRepository has undeclared type \OpenOrchestra\ModelInterface\Repository\StatusRepositoryInterface
Open

    public function __construct(
Severity: Minor
Found in Backoffice/Manager/ContentManager.php by phan

Argument 2 (replace) is int but \preg_replace() takes array|string
Open

            return preg_replace('/[0-9]+$/', $version, $label);
Severity: Minor
Found in Backoffice/Manager/ContentManager.php by phan

Return type of newVersionContent() is undeclared type \OpenOrchestra\ModelInterface\Model\ContentInterface
Open

    public function newVersionContent(ContentInterface $originalContent, $versionName = '')
Severity: Minor
Found in Backoffice/Manager/ContentManager.php by phan

Call to method getKeywords from undeclared class \OpenOrchestra\ModelInterface\Model\ContentInterface
Open

        foreach ($content->getKeywords() as $keyword) {
Severity: Critical
Found in Backoffice/Manager/ContentManager.php by phan

There are no issues that match your filters.

Category
Status