willdurand / Negotiation

Content Negotiation tools for PHP.
https://williamdurand.fr/Negotiation/
MIT License
1.41k stars 62 forks source link

Add $strict parameter to getBest() #86

Closed neural-wetware closed 7 years ago

neural-wetware commented 7 years ago

Add $strict parameter to getBest() to enable exceptions for invalid media types. Defaults to false so is backwards compatible.

willdurand commented 7 years ago

Ok, this looks good to me. I thought there was an interface for negotiators, which is not the case so this should be BC.

willdurand commented 7 years ago

thanks @neural-wetware!

willdurand commented 7 years ago

Please see #87

GuilhemN commented 7 years ago

@willdurand using func_num_args with func_get_arg should fix your bc issue ;)

if (3 >= func_num_args()) {
    $strict = func_get_arg(2);
} else {
    $strict = false;
}
willdurand commented 7 years ago

Yeah, not a huge fan of hacks.

GuilhemN commented 7 years ago

@willdurand why would it be a hack? This is provided by php and is known in other languages as well. Btw it is also used in symfony for bc layers.