Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,17 @@ $rules[] = Rule::allClasses()
->because('we want uniform naming for services');
```

### Match one of these names

```php
$rules[] = Rule::allClasses()
->that(new ResideInOneOfTheseNamespaces('App\Controller'))
->should(new MatchOneOfTheseNames(['*Controller', '*Action']))
->because('we want controllers to match one of these naming patterns');
```

*Note: Similar to HaveNameMatching, but accepts an array of patterns. The rule passes if the class name matches any of the provided patterns.*

### Implements an interface

```php
Expand All @@ -246,6 +257,17 @@ $rules[] = Rule::allClasses()
->because('all public controllers should not be container aware');
```

### Is a (inherits from or implements)

```php
$rules[] = Rule::allClasses()
->that(new ResideInOneOfTheseNamespaces('App\Domain\Event'))
->should(new IsA('App\Domain\DomainEvent'))
->because('all events should inherit from or implement DomainEvent');
```

*Note: This rule checks if a class inherits from or implements a given class/interface using PHP's `is_a()` function.*

### Is abstract

```php
Expand Down