Showing 33 of 41 total issues
Function buildOrderFromOrderCopy
has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring. Open
public function buildOrderFromOrderCopy(Model $order, stdClass $orderCopy): Model
{
// Order namespace
$orderClass = config('nikolag.connections.square.order.namespace');
// Set payment type to square
- 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 buildDiscounts
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
public function buildDiscounts(Collection $discounts, string $currency): array
{
$temp = [];
if ($discounts->isNotEmpty()) {
foreach ($discounts as $discount) {
- 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 createDiscounts
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
public function createDiscounts(array $discounts, string $scope, Model $parent = null): Collection
{
$temp = collect([]);
foreach ($discounts as $discount) {
//If discount doesn't have amount AND percentage in discounts table
- 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 buildOrderCopyFromArray
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
public function buildOrderCopyFromArray(array $order): stdClass
{
try {
$orderCopy = new stdClass();
// Create taxes Collection
- 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
File SquareService.php
has 284 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace Nikolag\Square;
use Nikolag\Core\Abstracts\CorePaymentService;
- Create a ticketCreate a ticket
Function buildOrderCopyFromModel
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public function buildOrderCopyFromModel(Model $order): stdClass
{
try {
$orderCopy = new stdClass();
// Create taxes Collection
- 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 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function charge(array $options): Transaction
{
$location_id = array_key_exists('location_id', $options) ? $options['location_id'] : null;
$currency = array_key_exists('currency', $options) ? $options['currency'] : 'USD';
$prepData = [
- Create a ticketCreate a ticket
Function createTaxes
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
public function createTaxes(array $taxes, string $scope, Model $parent = null): Collection
{
$temp = collect([]);
foreach ($taxes as $tax) {
//If percentage doesn't exist on a taxes table
- 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 buildOrderFromOrderCopy
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function buildOrderFromOrderCopy(Model $order, stdClass $orderCopy): Model
{
// Order namespace
$orderClass = config('nikolag.connections.square.order.namespace');
// Set payment type to square
- Create a ticketCreate a ticket
Function charge
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function charge(array $options): Transaction
{
$location_id = array_key_exists('location_id', $options) ? $options['location_id'] : null;
$currency = array_key_exists('currency', $options) ? $options['currency'] : 'USD';
$prepData = [
- 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 buildTaxes
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function buildTaxes(Collection $taxes): array
{
$temp = [];
if ($taxes->isNotEmpty()) {
foreach ($taxes as $tax) {
- 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 buildOrderCopyFromModel
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function buildOrderCopyFromModel(Model $order): stdClass
{
try {
$orderCopy = new stdClass();
// Create taxes Collection
- Create a ticketCreate a ticket
Method buildOrderCopyFromArray
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function buildOrderCopyFromArray(array $order): stdClass
{
try {
$orderCopy = new stdClass();
// Create taxes Collection
- Create a ticketCreate a ticket
Method buildDiscounts
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function buildDiscounts(Collection $discounts, string $currency): array
{
$temp = [];
if ($discounts->isNotEmpty()) {
foreach ($discounts as $discount) {
- Create a ticketCreate a ticket
Method addProductFromArray
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function addProductFromArray(stdClass $orderCopy, Model $order, array $product, int $quantity): Product|stdClass
{
try {
// Get quantity
$tempQuantity = null;
- Create a ticketCreate a ticket
Method createDiscounts
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function createDiscounts(array $discounts, string $scope, Model $parent = null): Collection
{
$temp = collect([]);
foreach ($discounts as $discount) {
//If discount doesn't have amount AND percentage in discounts table
- Create a ticketCreate a ticket
Function createProductFromModel
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function createProductFromModel(Model $product, Model $order = null, int $quantity = 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 buildProducts
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function buildProducts(Collection $products, string $currency): array
{
$temp = [];
if ($products->isNotEmpty()) {
foreach ($products as $product) {
- Create a ticketCreate a ticket
Consider simplifying this complex logical expression. Open
if ($key
&& $key != 'taxes'
&& $key != 'discounts'
&& $key != 'products'
&& $key != $property
- Create a ticketCreate a ticket
Consider simplifying this complex logical expression. Open
if ((! $discount->pivot && $discount->scope === Constants::DEDUCTIBLE_SCOPE_PRODUCT) ||
($discount->pivot && $discount->pivot->scope === Constants::DEDUCTIBLE_SCOPE_PRODUCT)) {
return self::_calculateProductDiscounts($products, $discount);
} elseif ((! $discount->pivot && $discount->scope === Constants::DEDUCTIBLE_SCOPE_ORDER) ||
($discount->pivot && $discount->pivot->scope === Constants::DEDUCTIBLE_SCOPE_ORDER)) {
- Create a ticketCreate a ticket