/** * Sets the distance between two {@link City}s * @param string $cityA name of city * @param string $cityB name of city * @param int $distance distance between cities */ public function setCityDistance($cityA, $cityB, $distance) { Validator::stringType()->notBlank()->check($cityA); Validator::stringType()->notBlank()->check($cityB); Validator::intType()->positive()->check($distance); $this->adjacencyMatrix[$cityA][$cityB] = $distance; $this->adjacencyMatrix[$cityB][$cityA] = $distance; }
/** * Returns the time when the rider arrives at the given floor for the first time. * * Time is represented as the number of instructions followed, starting with 1. * * @param ElevatorRide $ride * @param int $floor * @return int|null $time null if never arrived */ public static function firstArrivesAtFloor(ElevatorRide $ride, $floor) { Validator::intType()->check($floor); $time = array_search($floor, $ride->getRide(), true); if ($time === false) { return false; } return $time; }
function ajaxPublic($page = 0) { $validate_page = Validator::intType(); if (!$validate_page->validate($page)) { return; } RPC::call('MovimTpl.fill', '#public_list', $this->preparePublic($page)); }
function load() { if ($this->_view == 'node') { $this->_from = $this->get('s'); $this->_node = $this->get('n'); if (!$this->validateServerNode($this->_from, $this->_node)) { return; } $pd = new \Modl\ItemDAO(); $this->_item = $pd->getItem($this->_from, $this->_node); $this->_mode = 'group'; $this->url = Route::urlize('node', array($this->_from, $this->_node)); } elseif ($this->_view == 'tag' && $this->validateTag($this->get('t'))) { $this->_mode = 'tag'; $this->_tag = $this->get('t'); $this->title = '#' . $this->_tag; } else { $this->_from = $this->get('f'); $cd = new \modl\ContactDAO(); $this->_contact = $cd->get($this->_from, true); if (filter_var($this->_from, FILTER_VALIDATE_EMAIL)) { $this->_node = 'urn:xmpp:microblog:0'; } else { return; } $this->_mode = 'blog'; $this->url = Route::urlize('blog', $this->_from); } $pd = new \modl\PostnDAO(); if ($this->_id = $this->get('i')) { if (Validator::intType()->between(0, 100)->validate($this->_id)) { if (isset($this->_tag)) { $this->_messages = $pd->getPublicTag($this->get('t'), $this->_id * $this->_paging, $this->_paging + 1); } else { $this->_messages = $pd->getNodeUnfiltered($this->_from, $this->_node, $this->_id * $this->_paging, $this->_paging + 1); } $this->_page = $this->_id + 1; } elseif (Validator::stringType()->length(5, 100)->validate($this->_id)) { $this->_messages = $pd->getPublicItem($this->_from, $this->_node, $this->_id); if (is_object($this->_messages[0])) { $this->title = $this->_messages[0]->title; $description = stripTags($this->_messages[0]->contentcleaned); if (!empty($description)) { $this->description = $description; } $attachements = $this->_messages[0]->getAttachements(); if ($attachements && array_key_exists('pictures', $attachements)) { $this->image = urldecode($attachements['pictures'][0]['href']); } } if ($this->_view == 'node') { $this->url = Route::urlize('node', array($this->_from, $this->_node, $this->_id)); } else { $this->url = Route::urlize('blog', array($this->_from, $this->_id)); } } } else { $this->_page = 1; if (isset($this->_tag)) { $this->_messages = $pd->getPublicTag($this->get('t'), 0, $this->_paging + 1); } else { $this->_messages = $pd->getNodeUnfiltered($this->_from, $this->_node, 0, $this->_paging + 1); } } if (count($this->_messages) == $this->_paging + 1) { array_pop($this->_messages); } $this->user = new User($this->_from); $cssurl = $this->user->getDumpedConfig('cssurl'); if (isset($cssurl) && $cssurl != '' && Validator::url()->validate($cssurl)) { $this->addrawcss($cssurl); } }
/** * Returns the input in `input.txt` within a given day's directory. * * *Example:* Providing `1` for the day will return contents in `/src/main/Day1/input.txt` * * @param int $day * @return string contents of input file */ public function getInputFromFileForDay($day) { Validator::intType()->check($day); return $this->resourceProvider->getResource("Day{$day}/input.txt"); }