-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
22 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |