public static function autoload($className) { if (StringHelper::strEndsWith($className, 'Controller')) { require APPLICATION_PATH . '/controllers/' . $className . '.php'; } elseif (StringHelper::strStartsWith($className, 'Model_')) { list(, $name) = explode('_', $className); require APPLICATION_PATH . '/models/' . $name . '.php'; } else { require APPLICATION_PATH . '/libs/' . $className . '.php'; } }
/** * Retrieves an array of siblings * @param \Navinator\Collection $collection Collection context get siblings from * @param bool $includeSelf If true this node will be included in the list */ public function getSiblings(\Navinator\Collection $collection, $includeSelf = false) { $siblings = array(); $depth = $this->getDepth(); if ($depth == 1) { $siblings = $collection->getRootNodes(); } else { $parentPath = $this->getParentPath(); foreach ($collection->getNode() as $node) { if (StringHelper::strStartsWith($parentPath . '/', $node->getPath()) && $node->getDepth() == $depth) { $siblings[$node->getPath()] = $node; } } } if (!$includeSelf) { unset($siblings[$this->getPath()]); } return $siblings; }
/** * * @dataProvider testStartsWithProvider */ public function testStartsWith($prefix, $string, $outcome) { $this->assertEquals($outcome, StringHelper::strStartsWith($prefix, $string)); }