Skip to content

Commit bd759c9

Browse files
committed
updated readme
1 parent de2414c commit bd759c9

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

README.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
[![Coverage Status](https://coveralls.io/repos/github/reinder83/binary-flags/badge.svg?branch=master&v=1)](https://coveralls.io/github/reinder83/binary-flags?branch=master)
33

44
# BinaryFlags
5-
With this class you can easily add flags to your models.
5+
With this class you can easily add flags to your projects.
66

77
The number of flags you can use is limited to the architecture of your system, e.g.: 32 flags on a 32-bit system or 64 flags on 64-bit system.
88
To store 64-bits flags in a database, you will need to store it as UNSIGNED BIGINT in MySQL or an equivalant in your datastorage.
@@ -12,7 +12,7 @@ This package also comes with a trait which you can use to implement binary flags
1212
## Installing
1313
To install this package simply run the following command in the root of your project.
1414
```
15-
composer require reinder83\binary-flags
15+
composer require reinder83/binary-flags
1616
```
1717

1818
## Methods
@@ -22,29 +22,32 @@ The following methods can be used:
2222
Overwrite the current mask.
2323
This can be passed as first argument in the constructor.
2424

25-
##### getMask()
25+
##### getMask(): int
2626
Retrieve the current mask.
2727

2828
##### setOnModifyCallback(callable $onModify)
2929
Set a callback function which is called when the mask changes.
30-
This can be passed as second argument in the contructor.
30+
This can be passed as second argument in the constructor.
3131

3232
##### getFlagNames([int $mask, [bool $asArray=false]])
3333
Give the name(s) for the given `$mask` or the current mask when omitted.
3434
When `$asArray` is `true` the method will return an array with the names,
3535
otherwise an comma separated string will be returned (default).
3636

3737
##### addFlag(int $flag)
38-
Adds one or multiple flags the to current mask.
38+
Adds one or multiple flags to the current mask.
3939

4040
##### removeFlag(int $flag)
4141
Removes one or multiple flags from the current mask.
4242

43-
##### checkFlag(int $flag, [bool $checkAll=true])
43+
##### checkFlag(int $flag, [bool $checkAll=true]): bool
4444
Check if given flag(s) are set in the current mask.
4545
By default it will check all bits in the given flag.
4646
When you want to match any of the given flags set `$checkAll` to `false`.
4747

48+
##### checkAnyFlag(int $mask): bool
49+
For you convenient I've added an alias to checkFlag with `$checkAll` set to `false`.
50+
4851
## Example usage
4952

5053
Below some example usage code
@@ -98,7 +101,7 @@ var_export($exampleFlags->checkFlag(ExampleFlags::FOO | ExampleFlags::BAZ));
98101
var_export($exampleFlags->checkFlag(ExampleFlags::FOO | ExampleFlags::BAR));
99102
// true because both flags are set
100103

101-
var_export($exampleFlags->checkFlag(ExampleFlags::FOO | ExampleFlags::BAZ, true));
104+
var_export($exampleFlags->checkFlag(ExampleFlags::FOO | ExampleFlags::BAZ, false));
102105
// true because one of the flags is set (FOO)
103106
```
104107

@@ -121,7 +124,7 @@ array (
121124
)
122125
*/
123126

124-
// get mask of given mask
127+
// get flag names of given mask
125128
var_export($exampleFlags->getFlagNames(ExampleFlags::FOO | ExampleFlags::BAR));
126129
// 'Foo, Bar'
127130
```

0 commit comments

Comments
 (0)