Showing 15 of 15 total issues
Function loadV1
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
private function loadV1(\SimpleXmlElement $xml, \Dice\Dice $dice)
{
foreach ($xml as $key => $value) {
$rule = $dice->getRule((string) $value->name);
- 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 getParams
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
private function getParams(\ReflectionMethod $method, array $rule)
{
$paramInfo = []; // Caches some information about the parameter so (slow) reflection isn't needed every time
foreach ($method->getParameters() as $param) {
// get the class hint of each param, if there is one
- 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 loadV2
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
private function loadV2(\SimpleXmlElement $xml, \Dice\Dice $dice)
{
foreach ($xml as $key => $value) {
$rule = $dice->getRule((string) $value->name);
- 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 create
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
public function create($classname, array $args = [], array $share = [])
{
if (!empty($this->instances[$classname])) {
// we've already created a shared instance so return it to save the closure call.
return $this->instances[$classname];
- 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 create
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function create($classname, array $args = [], array $share = [])
{
if (!empty($this->instances[$classname])) {
// we've already created a shared instance so return it to save the closure call.
return $this->instances[$classname];
Method getParams
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getParams(\ReflectionMethod $method, array $rule)
{
$paramInfo = []; // Caches some information about the parameter so (slow) reflection isn't needed every time
foreach ($method->getParameters() as $param) {
// get the class hint of each param, if there is one
Method loadV1
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function loadV1(\SimpleXmlElement $xml, \Dice\Dice $dice)
{
foreach ($xml as $key => $value) {
$rule = $dice->getRule((string) $value->name);
Method loadV2
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function loadV2(\SimpleXmlElement $xml, \Dice\Dice $dice)
{
foreach ($xml as $key => $value) {
$rule = $dice->getRule((string) $value->name);
Function expand
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private function expand($param, array $share = [], $createFromString = false)
{
if (!\is_array($param)) {
// doesn't need any processing
return (is_string($param) && $createFromString) ? $this->create($param) : $param;
- 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 \call_user_func($param[self::INSTANCE]);
Avoid too many return
statements within this method. Open
return $this->create($param[self::INSTANCE], (is_array($args)) ? \array_merge($args, $share) : $share);
Avoid too many return
statements within this method. Open
return $object;
Avoid too many return
statements within this method. Open
return $this->cache[$classname]($args, $share);
Function getRule
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function getRule($name)
{
// first, check for exact match
$normalname = self::normalizeName($name);
- 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 addRule
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function addRule($classname, $rule)
{
if (isset($rule['instanceOf'])
&& \is_string($rule['instanceOf'])
&& (!\array_key_exists('inherit', $rule) || $rule['inherit'] === true)
- 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"