-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathFlyableTrait.php
More file actions
46 lines (36 loc) · 850 Bytes
/
FlyableTrait.php
File metadata and controls
46 lines (36 loc) · 850 Bytes
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
<?php
trait FlyableTrait {
private $leftWing;
private $rightWing;
public function fly() {
if ($this -> leftWing == null || $this -> rightWing == null)
throw new BadMethodCallException('Kanatlarım olmadan uçamam.<br>');
echo 'Uçabiliyorum.<br>';
}
public function setWing(string $whichWing, WingClass $wing) {
switch ($whichWing) {
case 'left' :
$this -> leftWing = $wing;
break;
case 'right' :
$this -> rightWing = $wing;
break;
default :
throw new InvalidArgumentException('Tanımsız kanat');
break;
}
}
public function getWing(string $whichWing) {
switch ($whichWing) {
case 'left' :
return $this -> leftWing;
break;
case 'right' :
return $this -> rightWing;
break;
default :
throw new InvalidArgumentException('Tanımsız kanat');
break;
}
}
}