Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. LinesOfCode.php

function LinesOfCode::__construct

@psalm-param non-negative-int $linesOfCode @psalm-param non-negative-int $commentLinesOfCode @psalm-param non-negative-int $nonCommentLinesOfCode @psalm-param non-negative-int $logicalLinesOfCode

Throws

IllogicalValuesException

NegativeValueException

File

vendor/sebastian/lines-of-code/src/LinesOfCode.php, line 46

Class

LinesOfCode
@psalm-immutable

Namespace

SebastianBergmann\LinesOfCode

Code

public function __construct(int $linesOfCode, int $commentLinesOfCode, int $nonCommentLinesOfCode, int $logicalLinesOfCode) {
    
    /** @psalm-suppress DocblockTypeContradiction */
    if ($linesOfCode < 0) {
        throw new NegativeValueException('$linesOfCode must not be negative');
    }
    
    /** @psalm-suppress DocblockTypeContradiction */
    if ($commentLinesOfCode < 0) {
        throw new NegativeValueException('$commentLinesOfCode must not be negative');
    }
    
    /** @psalm-suppress DocblockTypeContradiction */
    if ($nonCommentLinesOfCode < 0) {
        throw new NegativeValueException('$nonCommentLinesOfCode must not be negative');
    }
    
    /** @psalm-suppress DocblockTypeContradiction */
    if ($logicalLinesOfCode < 0) {
        throw new NegativeValueException('$logicalLinesOfCode must not be negative');
    }
    if ($linesOfCode - $commentLinesOfCode !== $nonCommentLinesOfCode) {
        throw new IllogicalValuesException('$linesOfCode !== $commentLinesOfCode + $nonCommentLinesOfCode');
    }
    $this->linesOfCode = $linesOfCode;
    $this->commentLinesOfCode = $commentLinesOfCode;
    $this->nonCommentLinesOfCode = $nonCommentLinesOfCode;
    $this->logicalLinesOfCode = $logicalLinesOfCode;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal