/** * @covers ::remove */ public function testRemove() { $array = ["headzoo", "joe", "sam"]; $this->assertEquals(0, Arrays::remove($array, "amy")); $this->assertEquals(1, Arrays::remove($array, "headzoo")); $this->assertEquals(["joe", "sam"], $array); $array = ["headzoo", "joe", "sam"]; $this->assertEquals(1, Arrays::remove($array, "headzoo", false, true)); $this->assertEquals([1 => "joe", "sam"], $array); $array = ["headzoo", "headzoo", "joe", "sam", "headzoo", "joe"]; $this->assertEquals(3, Arrays::remove($array, "headzoo")); $this->assertEquals(["joe", "sam", "joe"], $array); }
/** * Stops handling an uncaught exception * * Tells the class to stop handling the given type of exception, which may be either * a class name, or object. Returns true if the exception type has been successfully * unhandled. A false return value means the class wasn't handling the given * exception. * * Uses the currently running environment when none is given. * * Examples: * ```php * $handler->removeUncaughtException(LogicError::class); * * $handler->removeUncaughtException("live", LogicError::class); * * $handler->removeUncaughtException("dev", InvalidArgumentException::class); * ``` * * @param string|Exception|string $env Name of the environment * @param Exception|string|null $exception The exception to check * * @return bool */ public function removeUncaughtException($env, $exception = null) { $this->swapArgs($env, $exception, $this->running_env); $is_removed = false; if (isset($this->exceptions[$env])) { $exception = Objects::getFullName($exception); $is_removed = (bool) Arrays::remove($this->exceptions[$env], $exception); } return $is_removed; }