src/Resource/Customer/SubscriptionResource.php
Function create
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
Open
public function create($amount, $interval, $description, $times = null, array $opts = array())
{
// Check number of times
if (isset($times) && ($times < 1 || !is_numeric($times))) {
throw new \InvalidArgumentException("Invalid number of charges for this subscription. Please enter a number of 1 or more, or leave null for an ongoing subscription.");
- 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 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
public function create($amount, $interval, $description, $times = null, array $opts = array())
Missing class import via use statement (line '91', column '46'). Open
Open
$opts['startDate'] = new \DateTime($opts['startDate']);
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '84', column '23'). Open
Open
throw new \InvalidArgumentException("Invalid number of charges for this subscription. Please enter a number of 1 or more, or leave null for an ongoing subscription.");
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '93', column '31'). Open
Open
throw new \InvalidArgumentException("Option startDate must be a valid DateTime object or date string, preferably yyyy-mm-dd.");
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}