Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Proxy Example #106

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1220,15 +1220,15 @@ class LabDoor implements Door
}
}
```
Then we have a proxy to secure any doors that we want
Then we expose a proxy for creating secure doors
```php
class Security
class SecureDoor implements Door
{
protected $door;

public function __construct(Door $door)
public function __construct()
{
$this->door = $door;
$this->door = new LabDoor();
}

public function open($password)
Expand All @@ -1240,20 +1240,20 @@ class Security
}
}

public function authenticate($password)
{
return $password === '$ecr@t';
}

public function close()
{
$this->door->close();
}

private function authenticate($password)
{
return $password === '$ecr@t';
}
}
```
And here is how it can be used
```php
$door = new Security(new LabDoor());
$door = new SecureDoor();
$door->open('invalid'); // Big no! It ain't possible.

$door->open('$ecr@t'); // Opening lab door
Expand Down