I need to get all weekdays from bitmask. Is there some function to decompose the bitmask?

For example:

```php
const MONDAY    = 1 << 0; // 1
const TUESSAY   = 1 << 1; // 2
const WEDNESDAY = 1 << 2; // 4
const THURSSAY  = 1 << 3; // 8
const FRIDAY    = 1 << 4; // 16
const SATURDAY  = 1 << 5; // 32
const SUNDAY    = 1 << 6; // 64

function bitmaskToArray(int $bitmask): array
{
    //...
}

$wednesdayAndMonday = WEDNESDAY | MONDAY;

var_dump(bitmaskToArray($wednesdayAndMonday));

```

I see one solution, but I believe it's not the best one:

```php
const WEEKDAYS = [
    MONDAY,
    TUESSAY,
    WEDNESDAY,
    THURSDAY,
    FRIDAY,
    SATURDAY,
    SUNDAY,
];

function bitmaskToArray(int $bitmask): array
{
    $result = [];
    foreach (WEEKDAYS as $weekday) {
        if ($bitmask & $weekday) {
            $result []= $weekday;
        }
    }

    return $result;
}

```