Skip to content

new Bitmask() or Bitmask::from doesn't take a bitmask #17

@Externaluse

Description

@Externaluse

Please forgive me if this is stupid.
I had expected to be able to instantiate a BitMask from a compiled integer, ie so that new Bitmask(3) would later allow me to check if both the Enum with the value of 1 and the one with the value of 2 would be set. This doesn't appear to work.

namespace app\Bitmasks;
use Cruxinator\BitMask\BitMask;
class TestFlags extends BitMask
{
    const GROUPA = 1 << 0;
    const GROUPB = 1 << 1;
    const GROUPC = 1 << 2;
}`

Now I was expecting to be able to do this:

$x = new TestFlags(3);
$x->isGROUPA(); // expected true
$x->isGROUPB(); // expected true
$x->isGROUPC(); // expected false

Instead of my expectation I receive Uncaught UnexpectedValueException: Value '3' is not part of the enum app\Bitmasks\TestFlags

Am I missing something obvious?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions