-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_user.php
71 lines (56 loc) · 1.58 KB
/
test_user.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
// class User
// {
// private $username;
// private $password;
// private $invitedBy;
// private function __construct($username, $password, $invitedBy = null)
// {
// $this->username = $username;
// $this->password = $password;
// $this->invitedBy = $invitedBy;
// }
// public static function signUp($username, $password)
// {
// return new User($username, $password);
// }
// public static function fromInvitation($username, $password, User $invitedBy)
// {
// return new User($username, $password, $invitedBy);
// }
// public function changePassword($newPassword)
// {
// $this->password = $newPassword;
// }
// }
// $newUser = User::signUp('john_doe', '1234');
// $newUser->changePassword('change_me');
// $another = User::fromInvitation('jane_doe', 'xyz', $newUser);
// var_dump($newUser);
// var_dump($another);
class Person
{
private $firstName;
private $lastName;
public function __construct($firstName, $lastName)
{
$this->setFirstName($firstName);
$this->setLastName($lastName);
}
public function setFirstName($firstName)
{
$this->firstName = trim($firstName);
}
public function setLastName($lastName)
{
$this->lastName = trim($lastName);
}
public function fullName()
{
return $this->firstName . ' ' . $this->lastName;
}
}
$person = new Person(' Ilike ', ' spaces ');
echo $person->fullName() . PHP_EOL;
$person->setFirstName('lolly');
echo $person->fullName() . PHP_EOL;