filterByErrorLevel example

TestError::warn(),
            TestError::warn(),
            TestError::warn(),
            TestError::notice(),
            TestError::notice(),
            TestError::unknown(),
        ]);

        static::assertCount(4, $errors->getErrors());
        static::assertCount(3, $errors->getWarnings());
        static::assertCount(2, $errors->getNotices());
        static::assertCount(1, $errors->filterByErrorLevel(TestError::LEVEL_UNKNOWN));
        static::assertCount(10, $errors->getElements());
        static::assertTrue($errors->blockResubmit());
    }

    public function testEmptyDoesNotThrow(): void
    {
        $errors = new ErrorCollection();

        static::assertCount(0, $errors->getErrors());
        static::assertCount(0, $errors->getWarnings());
        static::assertCount(0, $errors->getNotices());
        

        }

        return false;
    }

    /** * @return array<array-key, Error|null> */
    public function getErrors(): array
    {
        return $this->filterByErrorLevel(Error::LEVEL_ERROR);
    }

    /** * @return array<array-key, Error|null> */
    public function getWarnings(): array
    {
        return $this->filterByErrorLevel(Error::LEVEL_WARNING);
    }

    /** * @return array<array-key, Error|null> */
Home | Imprint | This part of the site doesn't use cookies.