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
Order
has 42 functions (exceeds 20 allowed). Consider refactoring. Open
class Order extends yupe\models\YModel
{
/**
*
*/
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)) {
- 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 search
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function search()
{
$criteria = new CDbCriteria;
$criteria->with = ['delivery', 'payment', 'client', 'status'];
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)) {
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'),
Method beforeSave
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function beforeSave()
{
$this->total_price = $this->getProductsCost();
if ($this->getIsNewRecord()) {
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']],
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()) {
- 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 applyCoupons
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function applyCoupons(array $coupons)
{
if (!$this->isCouponsAvailable()) {
return true;
}
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());
- 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
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()) {
- 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
Function updateOrderProducts
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function updateOrderProducts($products)
{
if (!$this->productsChanged) {
return;
}
- 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"