Showing 37 of 37 total issues
Method generatePassword
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function generatePassword($dictionary = null, $minEntropy = null, $level = null, $separators = null, $useVariations = null, $variations = null){
if ($dictionary === null){
$dictionary = $this->getDictionary();
} else if (!is_object($dictionary) || !in_array('DictionaryInterface', class_implements($dictionary))){
Method __construct
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
public function __construct($dictionary = null, $level = null, $separators = ' ', $minEntropies = null, $useVariations = true, $variations = null, $minWordSize = null, $minReadWordsWordSize = null, $prng = null){
Function getEntropy
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function getEntropy($password = '', $dictionary = null, $variationsCount = null, $lastOrSeparator = true, $separatorsCount = null){
if ($variationsCount === null) { $variationsCount = $this->getVariationsCount(); }
if ($separatorsCount === null) { $separatorsCount = ($lastOrSeparator!==false)?$this->getSeparatorsCount():1; }
else if (!is_int($variationsCount)) { throw new Exception ('$variationsCount must be an int'); }
if ($dictionary===null) {
- Read upRead up
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 getAlphabetSize
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function getAlphabetSize($dictionary = null, $variationsCount = null){
if ($dictionary === null){
$dictionary = $this->getDictionary();
} else if (!is_object($dictionary) || !in_array('synapp\info\tools\passwordgenerator\dictionary\DictionaryInterface', class_implements($dictionary))){
throw new Exception ('$dictionary must be an object implementing DictionaryInterface');
- Read upRead up
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 readWordsFromPDO
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function readWordsFromPDO($dbh = null, $table = null, $column = null, $add = null, $minWordSize = null){
if ($dbh === null) { $dbh = $this->defaultDbh; }
if ($table === null) { $table = $this->defaultTable; }
if ($column === null) { $column = $this->defaultColumn; }
if ($add === null) { $add = $this->defaultAdd; }
Function getMinEntropyForLevel
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function getMinEntropyForLevel($level = null, $minEntropies = null){
if ($level === null) { $level = $this->level; }
else if (!is_int($level)) { throw new Exception ('$level must be int'); }
if ($minEntropies === null) { $minEntropies = $this->minEntropies; }
else if (!is_array($minEntropies)) { throw new Exception ('$minEntropies must be array'); }
- Read upRead up
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 generatePassword
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function generatePassword($dictionary = null, $minEntropy = null, $level = null, $separators = null, $useVariations = null, $variations = null){
Method getEntropy
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function getEntropy($password = '', $dictionary = null, $variationsCount = null, $lastOrSeparator = true, $separatorsCount = null){
Method readWordsFromPDO
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function readWordsFromPDO($dbh = null, $table = null, $column = null, $add = null, $minWordSize = null){
Method applyVariation
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function applyVariation($word,$index,$variations,$last,&$appliedVariation){
Method __construct
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function __construct($input = null, $minWordSize = null, $format = null, $params = array(), $prng = null){
Function setMinEntropies
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function setMinEntropies($minEntropies, $default = false){
if (!is_array($minEntropies)||!isset($minEntropies[0])||!is_int($minEntropies[0])||$minEntropies[0]<=0){
throw new Exception ('$minEntropies must be an ascending ordered array of ints > 0');
}
for ($i = 1; $i<count($minEntropies); $i++){
- Read upRead up
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
Avoid too many return
statements within this method. Open
return $word;
Avoid too many return
statements within this method. Open
return $word;
Avoid too many return
statements within this method. Open
return $word.'/';
Avoid too many return
statements within this method. Open
return $word.($last?'.':',');
Function countWords
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function countWords($words = null, $minWordSize = null, $minReadWordsWordSize = null){
if ($words === null) { $words = $this->words; }
if ($minWordSize === null) { $minWordSize = $this->minWordSize; }
if ($minReadWordsWordSize === null) { $minReadWordsWordSize = $this->minReadWordsWordSize; }
if (!array($words)) { throw new Exception('$words must be an array'); }
- Read upRead up
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"