Skip to content
Snippets Groups Projects
Commit 069be914 authored by xamgore's avatar xamgore
Browse files

Stronger conditions for filtering parameters

parent 245b7c40
Branches
Tags
No related merge requests found
...@@ -42,7 +42,7 @@ class Model_Helper_CourseWorkBuilder extends Model_Helper_Builder ...@@ -42,7 +42,7 @@ class Model_Helper_CourseWorkBuilder extends Model_Helper_Builder
/** Must be called after subtype() */ /** Must be called after subtype() */
function & subject($id) { function & subject($id) {
if ($this->data['Subtype'] == Model_CourseWork::SCIENTIFIC) if ($this->data['Subtype'] === Model_CourseWork::SCIENTIFIC)
$id = self::COURSEWORK_DISCIPLINE_ID; $id = self::COURSEWORK_DISCIPLINE_ID;
if (!is_numeric($id) || $id <= 0) if (!is_numeric($id) || $id <= 0)
...@@ -53,6 +53,9 @@ class Model_Helper_CourseWorkBuilder extends Model_Helper_Builder ...@@ -53,6 +53,9 @@ class Model_Helper_CourseWorkBuilder extends Model_Helper_Builder
} }
function & subtype($name) { function & subtype($name) {
if (!is_string($name))
throw new InvalidArgumentException('Type is incorrect');
switch ($name) { switch ($name) {
case Model_CourseWork::DISCIPLINARY: case Model_CourseWork::DISCIPLINARY:
case Model_CourseWork::SCIENTIFIC: case Model_CourseWork::SCIENTIFIC:
......
...@@ -65,8 +65,18 @@ class Model_Helper_DisciplineBuilder extends Model_Helper_Builder ...@@ -65,8 +65,18 @@ class Model_Helper_DisciplineBuilder extends Model_Helper_Builder
} }
function & type($name) { function & type($name) {
if (!$name) // todo: enum if (!is_string($name))
throw new InvalidArgumentException('type is incorrect'); throw new InvalidArgumentException('Type is incorrect');
switch ($name) {
case Model_Discipline::EXAM:
case Model_Discipline::CREDIT:
case Model_Discipline::GRADING_CREDIT:
break;
default:
throw new InvalidArgumentException('Type is incorrect');
}
$this->data['Type'] = $name; $this->data['Type'] = $name;
return $this; return $this;
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment