Skip to content
Snippets Groups Projects
Commit 969bc99f authored by xamgore's avatar xamgore
Browse files

Strong check of existing fields

parent 635cfb53
Branches
Tags
No related merge requests found
......@@ -9,11 +9,17 @@ class Model_Helper_CourseWorkBuilder extends Model_Helper_Builder
'Lectures' => 0,
'Practice' => 0,
'Labs' => 0,
'Milestone' => null,
'IsLocked' => false,
'Type' => 'grading_credit',
];
if (count($this->data) < 11) # fixme: bad const
$required = [
'Subtype', 'IsLocked', 'Milestone', 'AuthorID', 'GradeID', 'FacultyID',
'SubjectID', 'Lectures', 'Practice', 'Labs', 'Type', 'SemesterID'
];
if (array_diff($required, array_keys($this->data)))
throw new InvalidArgumentException('not enough arguments');
return new Model_CourseWork($this->data, false);
......
......@@ -9,7 +9,12 @@ class Model_Helper_DisciplineBuilder extends Model_Helper_Builder
'Milestone' => 0,
];
if (count($this->data) < 12) # fixme: bad const
$required = [
'Subtype', 'IsLocked', 'Milestone', 'AuthorID', 'GradeID', 'FacultyID',
'SubjectID', 'Lectures', 'Practice', 'Labs', 'Type', 'SemesterID'
];
if (array_diff($required, array_keys($this->data)))
throw new InvalidArgumentException('not enough arguments');
return new Model_Discipline($this->data, false);
......
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