Skip to content

Utility Methods

ensureNotEmpty

The ensureNotEmpty method on the FixtureHelper checks that any given variable is not empty. If it is, it will throw a LogicException.

This method also includes the necessary annotations so that PHPStan and Psalm don't throw any errors afterward:

php
<?php

class MyFixture extends Fixture {
    public function load(): void {
        $salesChannel = $this->helper->SalesChannel()->getStorefrontSalesChannel();
        $this->helper->ensureNotEmpty($salesChannel); 

        // Static code analysis now knows that `$salesChannel` exists and is not empty/null.
        $salesChannel->getId();
    }
}

Released under the MIT License.