Alpha Framework 3.1.0 API Documentation

Inspector

Utility class for calculating some software metrics related to a project.

Tags
since
1.0
author

John Collins dev@alphaframework.org

license

http://www.opensource.org/licenses/bsd-license.php The BSD License

copyright

Copyright (c) 2018, John Collins (founder of Alpha Framework). All rights reserved.

Redistribution and use in source and binary forms, with or
without modification, are permitted provided that the
following conditions are met:

* Redistributions of source code must retain the above
  copyright notice, this list of conditions and the
  following disclaimer.
* Redistributions in binary form must reproduce the above
  copyright notice, this list of conditions and the
  following disclaimer in the documentation and/or other
  materials provided with the distribution.
* Neither the name of the Alpha Framework nor the names
  of its contributors may be used to endorse or promote
  products derived from this software without specific
  prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

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
since
1.0

$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
since
1.0

$fileCount

The count of the source code files in the project.

private int $fileCount = 0
Tags
since
1.0

$files

An array of the source code file names in the project.

private array<string|int, mixed> $files = array()
Tags
since
1.0

$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
since
1.0

$filesLOCResult

An array of fileName => lines of code to be populated by this class.

private array<string|int, mixed> $filesLOCResult = array()
Tags
since
1.0

$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
since
1.0

$rootDir

The directory to begin the calculations from.

private string $rootDir
Tags
since
1.0

$TLOC

The Total Lines of Code (TLOC) for the project.

private int $TLOC = 0
Tags
since
1.0

$TLOCLessComments

The Total Lines of Code (TLOC) for the project, less comments defined in $comments.

private int $TLOCLessComments = 0
Tags
since
1.0

Methods

__construct()

Constructor, default $rootDir is .

public __construct([string $rootDir = '.' ]) : mixed
Parameters
$rootDir : string = '.'
Tags
since
1.0
Return values
mixed

calculateLOC()

Calculates the Lines of Code (LOC).

public calculateLOC() : mixed
Tags
since
1.0
Return values
mixed

resultsToHTML()

Generates a HTML table containing the metrics results.

public resultsToHTML() : string
Tags
since
1.0
Return values
string

disregardCommentsLOC()

Filters comments from LOC metric.

private disregardCommentsLOC(string $sourceFile) : int
Parameters
$sourceFile : string
Tags
since
1.0
Return values
int

Search results