1
0
mirror of https://github.com/jupeter/clean-code-php.git synced 2025-09-26 22:18:59 +02:00

Code formatting - add spaces

This commit is contained in:
Piotr Plenik
2017-04-07 12:02:59 +02:00
parent 6c0df98589
commit 2d3bd93bb3

View File

@@ -34,7 +34,7 @@ $ymdstr = $moment->format('y-m-d');
``` ```
**Good**: **Good**:
```javascript ```php
$currentDate = $moment->format('y-m-d'); $currentDate = $moment->format('y-m-d');
``` ```
**[ back to top](#table-of-contents)** **[ back to top](#table-of-contents)**
@@ -104,6 +104,7 @@ Explicit is better than implicit.
**Bad:** **Bad:**
```php ```php
$l = ['Austin', 'New York', 'San Francisco']; $l = ['Austin', 'New York', 'San Francisco'];
foreach($i=0; $i<count($l); $i++) { foreach($i=0; $i<count($l); $i++) {
oStuff(); oStuff();
doSomeOtherStuff(); doSomeOtherStuff();
@@ -118,6 +119,7 @@ foreach($i=0; $i<count($l); $i++) {
**Good**: **Good**:
```php ```php
$locations = ['Austin', 'New York', 'San Francisco']; $locations = ['Austin', 'New York', 'San Francisco'];
foreach($i=0; $i<count($locations); $i++) { foreach($i=0; $i<count($locations); $i++) {
$location = $locations[$i]; $location = $locations[$i];
@@ -645,7 +647,7 @@ just do one thing.
class Airplane { class Airplane {
// ... // ...
public function getCruisingAltitude() { public function getCruisingAltitude() {
switch (this.type) { switch ($this->type) {
case '777': case '777':
return $this->getMaxAltitude() - $this->getPassengerCount(); return $this->getMaxAltitude() - $this->getPassengerCount();
case 'Air Force One': case 'Air Force One':
@@ -1048,6 +1050,7 @@ get into trouble.
```php ```php
class Rectangle { class Rectangle {
private $width, $height; private $width, $height;
public function __construct() { public function __construct() {
$this->width = 0; $this->width = 0;
$this->height = 0; $this->height = 0;
@@ -1136,7 +1139,7 @@ class Rectangle extends Shape {
class Square extends Shape { class Square extends Shape {
public function __construct { public function __construct {
parent::__construct(); parent::__construct();
this.length = 0; $this->length = 0;
} }
public function setLength($length) { public function setLength($length) {
@@ -1500,7 +1503,7 @@ class Employee {
$this->email = $email; $this->email = $email;
} }
setTaxData($ssn, $salary) { public function setTaxData($ssn, $salary) {
$this->taxData = new EmployeeTaxData($ssn, $salary); $this->taxData = new EmployeeTaxData($ssn, $salary);
} }
// ... // ...