/Users/johnr/Desktop/IA pdf Downloads/_New Projects Downloads May 7th/CS_IA_Mattew/Customer.class.php |
1 <?php
2 require 'vendor/autoload.php';
3 class Customer{
4
5 private $firstName;
6 private $middleName;
7 private $lastName;
8 private $email;
9 private $phoneNumber;
10 private $nationality;
11 private $location;
12
13 public function __construct($firstName, $middleName, $lastName, $email, $phoneNumber, $nationality, $IPAddress){
14 $this->firstName = $firstName;
15 $this->middleName = $middleName;
16 $this->lastName = $lastName;
17 $this->email = $email;
18 $this->phoneNumber = $phoneNumber;
19 $this->nationality = $nationality;
20 $this->location = $this->setLocation($IPAddress);
21 }
22 public function getFirstName (){
23 if(isset($this->firstName)){
24 return $this->firstName;
25 }
26 }
27 public function getMiddleName (){
28 if(isset($this->middleName)){
29 return $this->middleName;
30 }
31 }
32 public function getLastName (){
33 if(isset($this->lastName)){
34 return $this->lastName;
35 }
36 }
37
38 public function getEmail() {
39 if(isset($this->email)){
40 return $this->email;
41 }
42 }
43
44 public function getPhoneNumber() {
45 if(isset($this->phoneNumber)){
46 return $this->phoneNumber;
47 }
48 }
49
50 public function getNationality() {
51 if(isset($this->nationality)){
52 return $this->nationality;
53 }
54 }
55
56 public function getLocation(){
57 if(isset($this->location)){
58 return $this->location;
59 }
60 }
61
62 public function getFullName(){
63 if(isset($this->middleName)){
64 return $this->firstName." ".$this->middleName." ".$this->lastName;
65 }else{
66 return $this->firstName." ".$this->lastName;
67 }
68
69 }
70 public function setLocation($IPAdress) {
71 $ipinfodb = new \IPInfoDB\Api('c9244e50668e8e65273036bdb95362187a2db11e9cb9eda27e3d4f5a71b4d48f');
72
73 $result = $ipinfodb->getCity($IPAdress);
74
75 if ($result) {
76 return $result['cityName'].", ".$result['regionName'].", ".$result['countryName'];
77 }
78 }
79 }
80
81 ?>