Skip to content

Commit

Permalink
Update Task4.md
Browse files Browse the repository at this point in the history
  • Loading branch information
martiendt authored Oct 21, 2021
1 parent 3e3402e commit c375ae2
Showing 1 changed file with 22 additions and 32 deletions.
54 changes: 22 additions & 32 deletions Task4.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,31 @@
# Task 4

#### 1. Make the code below cleaner and readable
#### 1. This code is working perfectly but it's hard to maintain, please make the code below cleaner and readable

```php
public function getPrice() {
if($customer->group == 'distributor') {
if($customer->status == 'active') {
    if($customer->debt > 10000000) {
        return error('this customer cannot make a purchase due to his debt over limit');
    } else {
        return Price::get('distributor');
    }
} else {
    return error('this customer is not active')
}
        } elseif($customer->group == 'general') {
if($customer->status == 'active') {
    if($customer->debt > 10000000) {
        return error('this customer cannot make a purchase due to his debt over limit');
    } else {
        return Price::get('general');
    }
} else {
    return error('this customer is not active')
}
        } elseif($customer->group == 'general') {
if($customer->status == 'active') {
    if($customer->debt > 10000000) {
        return error('this customer cannot make a purchase due to his debt over limit');
    } else {
        return Price::get('general');
    }
} else {
    return error('this customer is not active')
}
if($customer->group == 'distributor') {
if($customer->status == 'active') {
    if($customer->debt > 10000000) {
        return error('this customer cannot make a purchase due to his debt over limit');
    } else {
        return Price::get('distributor');
    }
} else {
    return error('this customer is not active')
}
} elseif($customer->group == 'general') {
if($customer->status == 'active') {
    if($customer->debt > 10000000) {
        return error('this customer cannot make a purchase due to his debt over limit');
    } else {
        return Price::get('general');
    }
} else {
    return error('this customer is not active')
}
}
}
```

#### 2. After change the code, make a pull request
#### 2. After change the code, make a pull request

0 comments on commit c375ae2

Please sign in to comment.