Sometimes, you need to know not only can be things done or not, but also why things can be done.
Status describes current state of reason. It must be convertible to integer value - status weight. Status with higher weight worse then smaller weight. (Make sense for appending and joining.)
Reasons can be appended to other reasons. It operations can be matched with logical or
.
Reason with the lowest weight wins. If two reasons have same weight, those messages
will be merged.
// weight: 1
// messages: foo, bar
$first = new Reason(...);
// weight: 2
// messages: baz
$second = new Reason(...);
// weight: 1
// messages: foo, bar
$firstOrSecond = $first->orX($second);
// weight: 1
// messages: foobar
$third = new Reason(...);
// weight: 1
// messages: foo, bar, foobar
$firstOrThird = $first->orX($third);
Same behavior as appending, but reason with the highest weight wins.
Looks like logical and
operation.
// weight: 1
// messages: foo, bar
$first = new Reason(...);
// weight: 2
// messages: baz
$second = new Reason(...);
// weight: 2
// messages: baz
$firstAndSecond = $first->andX($second);
// weight: 1
// messages: foobar
$third = new Reason(...);
// weight: 1
// messages: foo, bar, foobar
$firstAndThird = $first->andX($third);
$ vendor/bin/phpunit