feat(doc): updated instanced demo

This commit is contained in:
Victor Westerlund 2023-04-18 20:27:20 +02:00 committed by GitHub
parent 5a6904b43f
commit 4e67f7ee07
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -27,17 +27,17 @@ Flags can also be scoped to a class by creating a new `FunctionFlags` instance.
```php
use FunctionFlags/FunctionFlags
$my_flag = new FunctionFlags("MY_FLAG");
$other_flag = new FunctionFlags("OTHER_FLAG");
$flags1 = new FunctionFlags(["FOO", "BAR"]);
$flags2 = new FunctionFlags(["BAR", "BIZ"]);
// Returns true if MY_FLAG is passed and present in $my_flag
// Returns true if FOO is passed and present in $flags1
function foo(int $flags = null): bool {
return $my_flag->isset(MY_FLAG);
return $flags2->isset(FOO);
}
foo(MY_FLAG); // true
foo(OTHER_FLAG|MY_FLAG); // true
foo(OTHER_FLAG); // false
foo(FOO); // true
foo(FOO|BIZ); // true
foo(BIZ); // false
foo(); // false
```
@ -89,4 +89,4 @@ Instanced|Description
--|--
`new FunctionFlags(string\|array\|null)`|Flag(s) to define as string or array of string. This method must be called before using the flag(s).
`FunctionFlags->define(string\|array)`|Flag(s) to define as string or array of string. This method must be called before using the flag(s).
`FunctionFlags->isset(constant)`|The constant you wish to check is set on your function or method call.
`FunctionFlags->isset(constant)`|The constant you wish to check is set on your function or method call.