elabftw/elabftw

View on GitHub
src/Make/MakePdf.php

Summary

Maintainability
A
3 hrs
Test Coverage

Method getHtml has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function getHtml(): string
    {
        $date = new DateTimeImmutable($this->Entity->entityData['date'] ?? date('Ymd'));

        $locked = $this->Entity->entityData['locked'];
Severity: Minor
Found in src/Make/MakePdf.php - About 1 hr to fix

    Function appendPdfs has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        private function appendPdfs(array $pdfs): void
        {
            foreach ($pdfs as $pdf) {
                // There will be cases where the merging will fail
                // due to incompatibilities of Mpdf (actually fpdi) with the pdfs
    Severity: Minor
    Found in src/Make/MakePdf.php - About 55 mins to fix

    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

    Function loopOverEntries has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        private function loopOverEntries(): void
        {
            $entriesCount = count($this->entityIdArr);
            foreach ($this->entityIdArr as $key => $id) {
                $this->Entity->setId($id);
    Severity: Minor
    Found in src/Make/MakePdf.php - About 45 mins to fix

    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

        public function __construct(private LoggerInterface $log, MpdfProviderInterface $mpdfProvider, AbstractEntity $entity, protected array $entityIdArr, bool $includeChangelog = false)
    Severity: Minor
    Found in src/Make/MakePdf.php - About 35 mins to fix

      There are no issues that match your filters.

      Category
      Status