/** * Generates a request based on the current apache variables. * @throws Exception */ public static function generate() { $headers = new Map(apache_request_headers()); $method = $_SERVER['REQUEST_METHOD']; $path = $_SERVER['REQUEST_URI']; switch ($headers->get('Content-Type', null)) { case 'application/json': $data = file_get_contents('php://input'); $values = json_decode($data, true); $params = new Map($values); break; case 'application/x-www-form-urlencoded': $params = new Map($_POST); break; default: if ($method === 'GET') { $params = new Map($_GET); } else { if ($method === 'POST' || $method === 'PUT') { $params = new Map($_POST); } else { $params = new Map(); } } break; } return new Request($path, $method, $headers, $params); }
/** * * @param <type> $table * @param ArrayIterator $params * @return ArrayObject */ public function search($table, ArrayIterator $params) { $this->searchParams = $params; $this->join(); if ($table == "analysis") { $this->statements->remove("type_event"); } $statement = "SELECT this_.* " . $this->selectAttributes() . " FROM {$table} this_ "; $statement .= $this->join(); $i = 0; $this->searchParams->rewind(); if ($this->searchParams->count() > 0 && !$this->searchParams->offsetExists('true')) { $statement .= " WHERE "; } while ($this->searchParams->valid()) { if ($this->statements->containsKey($this->searchParams->key())) { if ($i++ > 0) { $statement .= " AND "; } $clause = $this->statements->get($this->searchParams->key()); $statement .= str_replace(":" . $this->searchParams->key(), "'" . $this->searchParams->current() . "'", $clause['where']); } $this->searchParams->next(); } return $this->getObject($statement . " ORDER BY this_.date DESC, this_.id DESC"); }
public function testCopy() { $copy = $this->properties->copy(); $copy->set('foo5', 'bar5'); $this->assertEquals('bar5', $copy->get('foo5')); $this->assertEquals(null, $this->properties->get('foo5')); }
/** * @param <type> $key * @return Provider */ private function selectTypeOf($key) { if ($this->types->containsKey($key)) { return $this->types->get($key); } return null; }
/** @test */ public function removeAffectsGivenKeyOnly() { $map = new Map(array('foo' => 42, 'bar' => 1337)); $map->remove('foo'); $this->assertFalse($map->hasKey('foo')); $this->assertEquals(1337, $map->get('bar')); }
private static function isInstantiable(Clazz $clazz, Map $whitelist) { if ($clazz->isPrimitive()) { return true; } $instantiable = $whitelist->get($clazz); return $instantiable != null && $instantiable; }
/** * Moves the element from current position to end of array * * @param int|string $key The key * @return LRUMap */ protected function recordAccess($key) { foreach (parent::get($key) as $value) { unset($this->elements[$key]); $this->elements[$key] = $value; } return $this; }
/** * @dataProvider provides_keys */ public function test_common_and_exotic_keys($key) { $map = new Map(); $map->set($key, 'foo'); $this->assertSame('foo', $map->get($key, 'baz')); $this->assertCount(1, $map); $map->all(function ($v, $k) use($key) { $this->assertSame($key, $k); }); }
/** * Checks an relation to the indicated alliance. * * @param integer|boolean $aid * * @return mixed The relation mode or false */ protected function getAllyRelation($aid = false) { if (!$aid || !$this->aid) { return false; } $this->loadAllianceRelations(); if ($this->alliances->size() > 0 && $this->alliances->exists($aid)) { return $this->alliances->get($aid); } return false; }
public function getLineWithTitles() { return new ArrayObject($this->values->get("rowTitles")); }
<?php // Runs top to bottom (most important should be at the top) Map::get('/', 'home#index');
private function getNameByCode($code) { return $this->types->get($code); }
<?php //Shop Redirect to merchant Map::get('/', 'home#index'); Map::get('/about-us' . FORMAT, 'staticpage#about'); Map::get('/contact-us' . FORMAT, 'staticpage#contact'); Map::get('/privacy-policy' . FORMAT, 'staticpage#privacy'); Map::get('/brand-index/(.*)', 'brandIndex#index'); Map::get('/cat-by-brand/(.*)', 'brandIndex#catByBrand'); Map::get('/product-by-cat/(.*)', 'brandIndex#productByCategory'); Map::get('/shop', 'shop#index'); Map::get('/shop/categories/(.*)' . FORMAT, 'categories#categories'); Map::get('/shop/brands/(.*)' . FORMAT, 'categories#brands'); Map::get('/shop/category/(.*)' . FORMAT, 'category#category'); Map::get('/shop/brand/(.*)' . FORMAT, 'category#brand'); Map::get('/shop/(.*)', 'product#index'); Map::get('/blog/page/(.*)', 'blog#index'); Map::get('/blog/category/(.*)', 'blog#category'); Map::get('/blog/(.*)', 'blog#article'); Map::get('/search/(.*)', 'search#index'); Map::get('/goto/(.*)', 'goto#index'); Map::get('/error', 'error#index'); Map::get('/(.*)', 'product#index');
public function getFonts() { return $this->map->get($this->id()); }
private function filetypeAllowed($filetype) { return $this->filetypeAllowed->get($filetype); }
/** * Get the map where the match was played on * @return Map Returns an invalid map if no map was found */ public function getMap() { return Map::get($this->map); }
<?php // Runs top to bottom (most important should be at the top) Map::get('/', 'welcome#index'); Map::resource('welcome');
/** * @dataProvider provider__construct */ public function test_remove($base, $diff) { $map = new Map($base); foreach ($base as $key => $value) { $this->assertEquals($map->get($key), $value); } foreach ($diff as $key => $value) { $map->remove($key); unset($base[$key]); } foreach ($base as $key => $value) { $this->assertEquals($map->get($key), $value); } }
<?php Map::get('/', 'welcome#index'); Map::get('/404', 'error_controller#error_index');