NikolaGavric94/laravel-square

View on GitHub

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
Severity: Minor
Found in src/builders/OrderBuilder.php - About 7 hrs to fix

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) {
Severity: Minor
Found in src/builders/SquareRequestBuilder.php - About 4 hrs to fix

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
Severity: Minor
Found in src/builders/DiscountBuilder.php - About 3 hrs to fix

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
Severity: Minor
Found in src/builders/OrderBuilder.php - About 3 hrs to fix

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;
Severity: Minor
Found in src/SquareService.php - About 2 hrs to fix

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
Severity: Minor
Found in src/builders/OrderBuilder.php - About 2 hrs to fix

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 = [
Severity: Major
Found in src/SquareService.php - About 2 hrs to fix

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
Severity: Minor
Found in src/builders/TaxesBuilder.php - About 2 hrs to fix

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
Severity: Major
Found in src/builders/OrderBuilder.php - About 2 hrs to fix

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 = [
Severity: Minor
Found in src/SquareService.php - About 2 hrs to fix

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) {
Severity: Minor
Found in src/builders/SquareRequestBuilder.php - About 1 hr to fix

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
Severity: Minor
Found in src/builders/OrderBuilder.php - About 1 hr to fix

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
Severity: Minor
Found in src/builders/OrderBuilder.php - About 1 hr to fix

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) {
Severity: Minor
Found in src/builders/SquareRequestBuilder.php - About 1 hr to fix

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;
Severity: Minor
Found in src/builders/ProductBuilder.php - About 1 hr to fix

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
Severity: Minor
Found in src/builders/DiscountBuilder.php - About 1 hr to fix

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
Severity: Minor
Found in src/builders/ProductBuilder.php - About 1 hr to fix

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) {
Severity: Minor
Found in src/builders/SquareRequestBuilder.php - About 1 hr to fix

Consider simplifying this complex logical expression.
Open

            if ($key
                && $key != 'taxes'
                && $key != 'discounts'
                && $key != 'products'
                && $key != $property
Severity: Major
Found in src/builders/OrderBuilder.php - About 1 hr to fix

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)) {
Severity: Major
Found in src/utils/Util.php - About 1 hr to fix
Severity
Category
Status
Source
Language