$badUrl = "example.com";
$resultArray = array_filter($startArray, function($arr) use ($badUrl) {
return !(isset($arr['url']) && $arr['url'] === $excludeUrl);
});
$badUrl = "example.com";
$resultArray = array_filter(
$startArray,
fn($arr) => !(isset($arr['url']) && $arr['url'] === $excludeUrl)
);
abstract class AbstractClass
{
protected function request($body)
{
return Document::TEST_VALUE;
}
}
class Document extends AbstractClass
{
const TEST_VALUE = 403;
public function handle($params)
{
$requestBody = 'body';
return $this->request($requestBody);
}
}
class DocumentTest
{
public function testRequest()
{
$doc = new Document();
$result = $this->invokeMethod($doc, 'request', [1]);
self::assertEquals(Document::TEST_VALUE, $result);
}
private function invokeMethod(&$object, $methodName, array $parameters = array())
{
$reflection = new \ReflectionClass(get_class($object));
$method = $reflection->getMethod($methodName);
$method->setAccessible(true);
return $method->invokeArgs($object, $parameters);
}
}
foreach ($filters as $filter) {
if ($filter['operation'] === 'in') {
$builder = $builder->whereHas('resource', function ($query) use ($filter) {
$query->whereIn($filter['name'], $filter['value']);
});
} else {
$builder = $builder->whereHas('resource', function ($query) use ($filter) {
$query->where($filter['name'], $filter['value']);
});
}
}