protected/modules/order/models/Order.php

Summary

Maintainability
F
3 days
Test Coverage

File Order.php has 550 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * @property integer $id
 * @property integer $delivery_id
 * @property double $delivery_price
Severity: Major
Found in protected/modules/order/models/Order.php - About 1 day to fix

    Order has 42 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Order extends yupe\models\YModel
    {
        /**
         *
         */
    Severity: Minor
    Found in protected/modules/order/models/Order.php - About 5 hrs to fix

      Function setProducts has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          public function setProducts($orderProducts)
          {
              $this->productsChanged = true;
              $orderProductsObjectsArray = [];
              if (is_array($orderProducts)) {
      Severity: Minor
      Found in protected/modules/order/models/Order.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 search has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function search()
          {
              $criteria = new CDbCriteria;
              $criteria->with = ['delivery', 'payment', 'client', 'status'];
      
      
      Severity: Minor
      Found in protected/modules/order/models/Order.php - About 1 hr to fix

        Method setProducts has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function setProducts($orderProducts)
            {
                $this->productsChanged = true;
                $orderProductsObjectsArray = [];
                if (is_array($orderProducts)) {
        Severity: Minor
        Found in protected/modules/order/models/Order.php - About 1 hr to fix

          Method attributeLabels has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function attributeLabels()
              {
                  return [
                      'id' => Yii::t('OrderModule.order', '#'),
                      'delivery_id' => Yii::t('OrderModule.order', 'Delivery method'),
          Severity: Minor
          Found in protected/modules/order/models/Order.php - About 1 hr to fix

            Method beforeSave has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function beforeSave()
                {
                    $this->total_price = $this->getProductsCost();
            
                    if ($this->getIsNewRecord()) {
            Severity: Minor
            Found in protected/modules/order/models/Order.php - About 1 hr to fix

              Method rules has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function rules()
                  {
                      return [
                          ['name, email, phone, zipcode, country, city, street, house, apartment', 'filter', 'filter' => 'trim'],
                          ['name, email, phone, zipcode, country, city, street, house, apartment, comment', 'filter', 'filter' => [$obj = new YPurifier(), 'purify']],
              Severity: Minor
              Found in protected/modules/order/models/Order.php - About 1 hr to fix

                Function beforeSave has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function beforeSave()
                    {
                        $this->total_price = $this->getProductsCost();
                
                        if ($this->getIsNewRecord()) {
                Severity: Minor
                Found in protected/modules/order/models/Order.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 applyCoupons has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function applyCoupons(array $coupons)
                    {
                        if (!$this->isCouponsAvailable()) {
                            return true;
                        }
                Severity: Minor
                Found in protected/modules/order/models/Order.php - About 1 hr to fix

                  Function getDeliveryCost has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function getDeliveryCost()
                      {
                          $cost = $this->delivery_price;
                          if ($this->isCouponsAvailable()) {
                              $validCoupons = $this->getValidCoupons($this->getCouponsCodes());
                  Severity: Minor
                  Found in protected/modules/order/models/Order.php - About 25 mins 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 getCouponDiscount has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function getCouponDiscount(array $coupons)
                      {
                          $productsTotalPrice = $this->getProductsCost();
                          $delta = 0.00;
                          if ($this->isCouponsAvailable()) {
                  Severity: Minor
                  Found in protected/modules/order/models/Order.php - About 25 mins 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 updateOrderProducts has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function updateOrderProducts($products)
                      {
                          if (!$this->productsChanged) {
                              return;
                          }
                  Severity: Minor
                  Found in protected/modules/order/models/Order.php - About 25 mins 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

                  There are no issues that match your filters.

                  Category
                  Status