forked from fencermonir/llc-php-0102
-
Notifications
You must be signed in to change notification settings - Fork 0
/
oop.php
53 lines (44 loc) · 1.04 KB
/
oop.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
<?php
class User
{
private $username, $phone_number;
public function setUsername($username): void
{
$this->username = strtolower($username);
}
public function setPhoneNumber($phone_number): void
{
if (strlen($phone_number) === 11) {
$this->phone_number = $phone_number;
}
}
public function getUsername(): string
{
return $this->username;
}
public function getPhoneNumber(): string
{
return str_replace(substr($this->phone_number, 0, 4), 'XXXX', $this->phone_number);
}
}
$shohan = new User();
$shohan->setUsername('Shohan');
$shohan->setPhoneNumber('01111111111');
echo $shohan->getPhoneNumber();
echo '<br/>';
$shoharto = new User();
$shoharto->setUsername('Shoharto');
$shoharto->setPhoneNumber('02222222222');
echo $shoharto->getPhoneNumber();
//
//echo '<br/>';
//
//$shoharto = new User();
//$shoharto->setUsername('Shoharto');
//$shoharto->show();
//
//echo '<br/>';
//
//$nipun = new User();
//$nipun->setUsername('Nipun');
//$nipun->show();