bufon2211 6 лет назад
Родитель
Сommit
8adaf53d64
3 измененных файлов с 77 добавлено и 0 удалено
  1. 31 0
      model/Languages.php
  2. 14 0
      model/ModelAbstract.php
  3. 32 0
      model/Student.php

+ 31 - 0
model/Languages.php

@@ -0,0 +1,31 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: mrs
+ * Date: 15.01.2018
+ * Time: 12:32
+ */
+
+namespace App\Model;
+
+
+class Languages extends ModelAbstract
+{
+    public $id;
+    public $name;
+
+    public function __construct(string $name, int $id = null)
+    {
+        $this->name = $name;
+        $this->id = $id;
+    }
+
+    public function validate(): bool
+    {
+        if (iconv_strlen($this->name) > 50 || iconv_strlen($this->name) < 2) {
+            return false;
+        }
+        return true;
+    }
+
+}

+ 14 - 0
model/ModelAbstract.php

@@ -0,0 +1,14 @@
+<?php
+
+/**
+ * Created by PhpStorm.
+ * User: artem
+ * Date: 21.05.17
+ * Time: 13:02
+ */
+namespace App\Model;
+
+abstract class ModelAbstract
+{
+    public abstract function validate(): bool;
+}

+ 32 - 0
model/Student.php

@@ -0,0 +1,32 @@
+<?php
+namespace App\Model;
+
+class Student extends ModelAbstract
+{
+    public $id;
+    public $firstName;
+    public $lastName;
+    public $class;
+
+    public function __construct(string $firstName, string $lastName, string $class, int $id = null)
+    {
+        $this->firstName = $firstName;
+        $this->lastName = $lastName;
+        $this->class = $class;
+        $this->id = $id;
+    }
+
+    public function validate(): bool
+    {
+        if (iconv_strlen($this->firstName) > 50 || iconv_strlen($this->firstName) < 2) {
+            return false;
+        }
+        if (iconv_strlen($this->lastName) > 50 || iconv_strlen($this->lastName) < 2) {
+            return false;
+        }
+        if (iconv_strlen($this->class) > 15 || iconv_strlen($this->lastName) < 2) {
+            return false;
+        }
+        return true;
+    }
+}