Inspector
Utility class for calculating some software metrics related to a project.
Tags
Table of Contents
- $comments : array<string|int, mixed>
- An array of the first characters of a comment line in source code.
- $excludeSubDirectories : array<string|int, mixed>
- Any sub-directories which you might want to exclude from the calculations.
- $fileCount : int
- The count of the source code files in the project.
- $files : array<string|int, mixed>
- An array of the source code file names in the project.
- $filesLOCNoCommentsResult : array<string|int, mixed>
- An array of fileName => lines of code to be populated by this class, excluding comment lines defined in the $comments array.
- $filesLOCResult : array<string|int, mixed>
- An array of fileName => lines of code to be populated by this class.
- $includeFileTypes : array<string|int, mixed>
- The file extensions of the file types to include in the calculations.
- $rootDir : string
- The directory to begin the calculations from.
- $TLOC : int
- The Total Lines of Code (TLOC) for the project.
- $TLOCLessComments : int
- The Total Lines of Code (TLOC) for the project, less comments defined in $comments.
- __construct() : mixed
- Constructor, default $rootDir is .
- calculateLOC() : mixed
- Calculates the Lines of Code (LOC).
- resultsToHTML() : string
- Generates a HTML table containing the metrics results.
- disregardCommentsLOC() : int
- Filters comments from LOC metric.
Properties
$comments
An array of the first characters of a comment line in source code.
private
array<string|int, mixed>
$comments
= array('/', '*', '#')
Tags
$excludeSubDirectories
Any sub-directories which you might want to exclude from the calculations.
private
array<string|int, mixed>
$excludeSubDirectories
= array('cache', 'lib', 'docs', 'attachments', 'dist', 'vendor')
Tags
$fileCount
The count of the source code files in the project.
private
int
$fileCount
= 0
Tags
$files
An array of the source code file names in the project.
private
array<string|int, mixed>
$files
= array()
Tags
$filesLOCNoCommentsResult
An array of fileName => lines of code to be populated by this class, excluding comment lines defined in the $comments array.
private
array<string|int, mixed>
$filesLOCNoCommentsResult
= array()
Tags
$filesLOCResult
An array of fileName => lines of code to be populated by this class.
private
array<string|int, mixed>
$filesLOCResult
= array()
Tags
$includeFileTypes
The file extensions of the file types to include in the calculations.
private
array<string|int, mixed>
$includeFileTypes
= array('.php', '.html', '.phtml', '.inc', '.js', '.css', '.xml')
Tags
$rootDir
The directory to begin the calculations from.
private
string
$rootDir
Tags
$TLOC
The Total Lines of Code (TLOC) for the project.
private
int
$TLOC
= 0
Tags
$TLOCLessComments
The Total Lines of Code (TLOC) for the project, less comments defined in $comments.
private
int
$TLOCLessComments
= 0
Tags
Methods
__construct()
Constructor, default $rootDir is .
public
__construct([string $rootDir = '.' ]) : mixed
Parameters
- $rootDir : string = '.'
Tags
Return values
mixed —calculateLOC()
Calculates the Lines of Code (LOC).
public
calculateLOC() : mixed
Tags
Return values
mixed —resultsToHTML()
Generates a HTML table containing the metrics results.
public
resultsToHTML() : string
Tags
Return values
string —disregardCommentsLOC()
Filters comments from LOC metric.
private
disregardCommentsLOC(string $sourceFile) : int
Parameters
- $sourceFile : string