/** * Inject routes into the provided router. * * @param Router $router * @return Router */ public function inject(Router $router) { $router->group(Arr::filterNullValues(['middleware' => $this->middleware, 'prefix' => $this->prefix]), function (Router $router) { Std::each(function (ResourceMethod $method) use($router) { $handler = vsprintf('%s@%s', [$this->controller, $method->getMethod()]); $router->match([$method->getVerb()], $method->getPath(), $handler); }, $this->methods); }); return $router; }
public function testFilterNullWithAllowed() { $this->assertEqualsMatrix([[['key1' => 'content'], Arr::filterNullValues(['key1' => 'content', 'key2' => null, 'otherkey' => null, 'otherkey2' => 'ishouldnotbehere'], ['key1'])], [['key1' => 'content', 'otherkey2' => 'ishouldnotbehere'], Arr::filterNullValues(['key1' => 'content', 'key2' => null, 'otherkey' => null, 'otherkey2' => 'ishouldnotbehere'])], [[], Arr::filterNullValues(['key1' => 'content', 'key2' => null, 'otherkey' => null, 'otherkey2' => 'ishouldnotbehere'], [])]]); }