Skip to content

Commit

Permalink
Add first draft of "Utility methods" page
Browse files Browse the repository at this point in the history
  • Loading branch information
jkniest committed Jun 16, 2024
1 parent 680e1d2 commit 646a036
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions docs/helpers/utility.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Utility Methods
## ensureNotEmpty
The `ensureNotEmpty` method on the fixture helper checks that any given variable is not [empty](#todo). If it is, it will throw a `LogicException`.

This method also includes the needed annotations, so that [PHPstan](#todo) and [Psalm](#todo) don't throw any errors afterwards:

```php
<?php

class MyFixture extends Fixture {
public function load(): void {
$salesChannel = $this->helper->SalesChannel()->getStorefrontSalesChannel();
$this->helper->ensureNotEmpty($salesChannel); // [!code focus]

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

0 comments on commit 646a036

Please sign in to comment.