} /** * @return string */ public function getName() { return $this->name; } /** * @return integer */ private function enrolled() { return $this->enrolled(); } } /* * The parameters here match those required by the class. * - Name of school * - Enrolled students */ $starkState = new School('Stark State', $enrolled = 8000); echo $starkState->getName(); echo "<br />"; $starkState->setLocation('Canton'); echo $starkState->getLocation(); /* * Due to this being private, it will throw an error: * Fatal error: Call to private method School::enrolled() */ // $starkState->enrolled();
public static function addSchools() { $class = get_called_class(); decho("Adding schools for {$class}"); foreach (static::getSchools() as $data) { print_r($data); $school = SchoolQuery::create()->filterByBookstoreType($class)->filterBySubdomain($data['Subdomain'])->findOne(); if (!$school) { $school = new School(); $school->setBookstoreType($class)->setSubdomain($data['Subdomain']); } $school->setSlug($data['Slug'])->setName($school->getName() ?: $data['Name'])->setShortName($school->getShortName(true) ?: (isset($data['ShortName']) ? $data['ShortName'] : School::guessShortName($data['Name'], $data['Slug'])))->setTouched(1)->save(); } }
/** * @param School $school * @param int $group * @param string $day */ public function assignToSchool($school, $group, $day) { $this->setAssignedSchool($school->getName()); if ($this->group == 1 && $group == 2 || $this->group == 2 && $group == 1) { $this->group = 3; } else { $this->setGroup($group); } $this->setAssignedDay($day); }