Showing 33 of 41 total issues
Function _saveCustomer
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private function _saveCustomer(): void
{
if (! $this->getCustomer()->payment_service_id) {
$response = $this->config->customersAPI()->createCustomer($this->getCreateCustomerRequest());
- Read upRead up
- Create a ticketCreate a ticket
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 charge
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
public function charge(float $amount, string $nonce, string $location_id, mixed $merchant, array $options = [], mixed $customer = null, string $currency = 'USD'): Transaction
- Create a ticketCreate a ticket
Function createProductFromArray
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function createProductFromArray(array $product, Model $order = null): Product|stdClass
{
$productObj = new stdClass();
//If product doesn't have quantity in pivot table
//throw new exception because every product should
- Read upRead up
- Create a ticketCreate a ticket
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 charge
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public function charge(float $amount, string $nonce, string $location_id, array $options = [], mixed $customer = null, string $currency = 'USD'): Transaction
- Create a ticketCreate a ticket
Consider simplifying this complex logical expression. Open
if ((isset($discount['amount']) && ($discount['amount'] != null || $discount['amount'] != 0)) &&
(isset($discount['percentage']) && ($discount['percentage'] != null || $discount['percentage'] != 0.0))
) {
throw new InvalidSquareOrderException('Both $amount and $percentage exist for object Discount, only 1 is allowed', 500);
}
- Create a ticketCreate a ticket
Consider simplifying this complex logical expression. Open
if ((! isset($discount['amount']) || $discount['amount'] == null || $discount['amount'] == 0) &&
(! isset($discount['percentage']) || $discount['percentage'] == null || $discount['percentage'] == '')) {
throw new MissingPropertyException('Both $amount and $percentage property for object Discount are missing, 1 is required', 500);
}
- Create a ticketCreate a ticket
Function buildProducts
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function buildProducts(Collection $products, string $currency): array
{
$temp = [];
if ($products->isNotEmpty()) {
foreach ($products as $product) {
- Read upRead up
- Create a ticketCreate a ticket
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 addProductFromArray
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function addProductFromArray(stdClass $orderCopy, Model $order, array $product, int $quantity): Product|stdClass
{
try {
// Get quantity
$tempQuantity = null;
- Read upRead up
- Create a ticketCreate a ticket
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 $totalDiscount;
- Create a ticketCreate a ticket
Avoid too many return
statements within this method. Open
return false;
- Create a ticketCreate a ticket
Function addProductFromModel
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function addProductFromModel(Model $order, Model $product, int $quantity): Product|stdClass
{
try {
// If quantity is null or 0
if ($quantity == null || $quantity == 0) {
- Read upRead up
- Create a ticketCreate a ticket
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 hasProduct
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function hasProduct(\Illuminate\Database\Eloquent\Collection|Collection $source, Product|int|array|null $product): bool
{
// Check if $product is either int, Model or array
if (is_a($product, Product::class)) {
return $source->contains($product);
- Read upRead up
- Create a ticketCreate a ticket
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 _saveOrder
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function _saveOrder(bool $saveToSquare = false): void
{
$this->order = $this->orderBuilder->buildOrderFromOrderCopy($this->getOrder(), $this->orderCopy);
//If property locationId doesn't exist throw error
if (! $this->locationId) {
- Read upRead up
- Create a ticketCreate a ticket
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"