mirror of
https://github.com/jupeter/clean-code-php.git
synced 2025-09-25 21:49:04 +02:00
add default value for User::$access
This commit is contained in:
@@ -124,6 +124,12 @@ $json = $serializer->serialize($data, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT
|
|||||||
**Bad:**
|
**Bad:**
|
||||||
|
|
||||||
```php
|
```php
|
||||||
|
class User
|
||||||
|
{
|
||||||
|
// What the heck is 7 for?
|
||||||
|
public $access = 7;
|
||||||
|
}
|
||||||
|
|
||||||
// What the heck is 4 for?
|
// What the heck is 4 for?
|
||||||
if ($user->access & 4) {
|
if ($user->access & 4) {
|
||||||
// ...
|
// ...
|
||||||
@@ -139,6 +145,8 @@ class User
|
|||||||
const ACCESS_CREATE = 2;
|
const ACCESS_CREATE = 2;
|
||||||
const ACCESS_UPDATE = 4;
|
const ACCESS_UPDATE = 4;
|
||||||
const ACCESS_DELETE = 8;
|
const ACCESS_DELETE = 8;
|
||||||
|
|
||||||
|
public $access = self::ACCESS_READ | self::ACCESS_CREATE | self::ACCESS_UPDATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($user->access & User::ACCESS_UPDATE) {
|
if ($user->access & User::ACCESS_UPDATE) {
|
||||||
|
Reference in New Issue
Block a user