From 44f11cbb1d1696bcc120efde56766d404100f147 Mon Sep 17 00:00:00 2001 From: stas Date: Tue, 21 May 2024 17:06:42 +0300 Subject: [PATCH] fifth --- Information.txt | 21 +++++------ form.php | 8 +++-- info.php | 38 ++++++-------------- src/AdditionallyInfo.php | 14 -------- src/Contacts.php | 17 --------- src/FullName.php | 19 ---------- src/Information.php | 75 ++++++++++++++++++++++++++++++++++------ table.php | 5 ++- 8 files changed, 95 insertions(+), 102 deletions(-) delete mode 100644 src/AdditionallyInfo.php delete mode 100644 src/Contacts.php delete mode 100644 src/FullName.php diff --git a/Information.txt b/Information.txt index 953de12..ee219b5 100644 --- a/Information.txt +++ b/Information.txt @@ -1,10 +1,11 @@ -Билай Станислав Романович; 2002-03-11; Мужчина; +79493761924; stasbilay02@yandex.ru; -Иванов Иван Иванович; 2002-03-11; Мужчина; +71111111111; dsjgbdskgb@yandex.ru; -Иванова Мария Сергеевна; 2002-04-05; Женжина; +382222222222; sdguhnlnoih@gmail.com; -Плешкова Анастасия Денисовна; 2006-11-10; Женжина; +73333333333; ple.anastasiya@gmail.com; -Зайцева Анжела Игоревна; 1998-12-12; Женжина; +74444444444; aksjfhfka@mail.ru; -Петров Петр Петрович; 1987-03-02; Мужчина; +77777777777; jksghhsdkj@gmail.com; -Зайцев Федор Александрович; 2014-12-22; Мужчина; +76667774441; asert@mail.ru; -Билай Станислав Романович;1111-11-11;Мужчина;+79493761924;stasbilay02@yandex.ru; -Плешкова Анастасия Денисовна;1111-11-11;Мужчина;+73333333333;ple.anastasiya@gmail.com; -Зайцев Федор Александрович;1234-12-12;Мужчина;+76667774441;asert@mail.ru; +Билай;Станислав;Романович;2002-03-11;Мужчина;+7;9493761924;stasbilay02@yandex.ru; +Иванов;Иван;Иванович;2002-03-11;Мужчина;+7;1111111111;dsjgbdskgb@yandex.ru; +Иванова;Мария;Сергеевна;2002-04-05;Женжина;+38;2222222222;sdguhnlnoih@gmail.com; +Плешкова;Анастасия;Денисовна;2006-11-10;Женжина;+7;3333333333;ple.anastasiya@gmail.com; +Зайцева;Анжела;Игоревна;1998-12-12;Женжина;+7;4444444444;aksjfhfka@mail.ru; +Петров;Петр;Петрович;1987-03-02;Мужчина;+7;7777777777;jksghhsdkj@gmail.com; +Зайцев;Федор;Александрович;2014-12-22;Мужчина;+7;6667774441;asert@mail.ru; +Билай;Станислав;Романович;1111-11-11;Мужчина;+7;9493761924;stasbilay02@yandex.ru; +Плешкова;Анастасия;Денисовна;1111-11-11;Мужчина;+7;3333333333;ple.anastasiya@gmail.com; +Зайцев;Федор;Александрович;1234-12-12;Мужчина;+7;6667774441;asert@mail.ru; +Билай;Станислав;Романович;1111-11-11;Мужчина;+38;9493761924;stasbilay02@yandex.ru diff --git a/form.php b/form.php index bd4bd00..4ab4627 100644 --- a/form.php +++ b/form.php @@ -1,9 +1,11 @@ - Фамилия:
+ Фамилия:


- Имя:
+ + Имя:


- Отчество (если есть):
+ + Отчество (если есть):


Дата Рождения:
diff --git a/info.php b/info.php index 797a0e9..632db8a 100644 --- a/info.php +++ b/info.php @@ -2,40 +2,22 @@ namespace src; -use AdditionallyInfo; -use Contacts; -use FullName; use Information; require_once "src/Information.php"; -require_once "src/FullName.php"; -require_once "src/Contacts.php"; -require_once "src/AdditionallyInfo.php"; -$surname = $_REQUEST["surname"]; -$name = $_REQUEST["name"]; -$patronymic = $_REQUEST["patronymic"]; +$fileName = "Information.txt"; +$fileModeOpen = "a"; -$fullName = new FullName($surname, $name, $patronymic); -$fullName = $fullName->getFoolName(); +$fullInformation = new Information(); +$fullInformation->load($_REQUEST); -$gender = $_REQUEST["gender"]; -$dateOfBirth = $_REQUEST["dateOfBirth"]; +echo "
";
+print_r($fullInformation);
+$string = $fullInformation->toString();
 
-$additionallyInfo = new AdditionallyInfo($dateOfBirth, $gender);
-$additionallyInfo = $additionallyInfo->getAdditionallyInfo();
-
-$countryCode = $_REQUEST["countryCode"];
-$phoneNumber = $_REQUEST["phoneNumber"];
-$email = $_REQUEST["email"];
-
-$contacts = new Contacts($countryCode, $phoneNumber, $email);
-$contacts = $contacts->getContacts();
-
-$fullInformation = new Information($fullName, $additionallyInfo, $contacts);
-$fullInformation = $fullInformation->getFullInformation();
-
-$file = fopen("Information.txt", "a");
-fwrite($file, $fullInformation);
+$file = fopen($fileName, $fileModeOpen);
+fwrite($file, $string);
 fclose($file);
+
 require "table.php";
\ No newline at end of file
diff --git a/src/AdditionallyInfo.php b/src/AdditionallyInfo.php
deleted file mode 100644
index 736d932..0000000
--- a/src/AdditionallyInfo.php
+++ /dev/null
@@ -1,14 +0,0 @@
-bDay = $bDay;
-        $this->gender = $gender;
-    }
-    public function getAdditionallyInfo() {
-        return $this->bDay . ";" . $this->gender;
-    }
-}
\ No newline at end of file
diff --git a/src/Contacts.php b/src/Contacts.php
deleted file mode 100644
index a9058f4..0000000
--- a/src/Contacts.php
+++ /dev/null
@@ -1,17 +0,0 @@
-countryCode = $countryCode;
-        $this->phoneNumber = $phoneNumber;
-        $this->email = $email;
-    }
-
-    public function getContacts(){
-        return $this->countryCode . $this->phoneNumber . ";" . $this->email;
-    }
-}
\ No newline at end of file
diff --git a/src/FullName.php b/src/FullName.php
deleted file mode 100644
index b21fcb5..0000000
--- a/src/FullName.php
+++ /dev/null
@@ -1,19 +0,0 @@
-surname = $surname;
-        $this->name = $name;
-        $this->patronymic = $patronymic;
-    }
-    public function getFoolName()
-    {
-        return $this->surname . ' ' . $this->name . ' ' . $this->patronymic;
-    }
-}
diff --git a/src/Information.php b/src/Information.php
index 6085535..65d1aa5 100644
--- a/src/Information.php
+++ b/src/Information.php
@@ -1,22 +1,77 @@
 foolName = $foolName;
-        $this->additionallyInfo = $additionallyInfo;
-        $this->contacts = $contacts;
+
     }
 
-    public function getFullInformation()
+    /**
+     * @param array $dataArray
+     * @return void
+     */
+    public function load(array $dataArray): void
     {
-        return $this->foolName . ";" . $this->additionallyInfo . ";" . $this->contacts . ";\n";
+        if ($dataArray) {
+            $this->surname = $dataArray['surname'] ?? '';
+            $this->name = $dataArray['name'] ?? '';
+            $this->patronymic = $dataArray['patronymic'] ?? '';
+            $this->dateOfBirth = $dataArray['dateOfBirth'] ?? '';
+            $this->gender = $dataArray['gender'] ?? '';
+            $this->countryCode = $dataArray['countryCode'] ?? '';
+            $this->phoneNumber = $dataArray['phoneNumber'] ?? '';
+            $this->email = $dataArray['email'] ?? '';
+        }
+    }
+
+    /**
+     * @param string $key
+     * @return string|null
+     */
+    public function getByKey(string $key): ?string
+    {
+        if (isset($this->{$key})) {
+            return $this->{$key};
+        }
+
+        return null;
+    }
+
+    /**
+     * @return string
+     */
+    public function toString(): string
+    {
+        return $this->surname . ';' . $this->name . ';' . $this->patronymic . ';' . $this->dateOfBirth . ';' .
+            $this->gender . ';' . $this->countryCode . ';' . $this->phoneNumber . ';' . $this->email . "\n";
+    }
+
+    public function search()
+    {
+
     }
 }
 
diff --git a/table.php b/table.php
index dd8a215..8b033a3 100644
--- a/table.php
+++ b/table.php
@@ -38,9 +38,12 @@
     Инфрмацмонная таблица 
     
-            
+            
+            
+            
+            
ФИОФамилияИмяОтчество Дата рождения ПолКод страны Номер Телефона Email