For a custom logger I want to force the caller to pass a valid class constant defined in PsrLogLogLevel. This class is defined like: The loggers’ function (wrong) looks like: This does not work because LogLevel::DEBUG for instance is a string and not an instance of the class. Is there any way to enforce a class constant in a PHP
Tag: class-constants
Get value of dynamically chosen class constant in PHP
I would like to be able to do something like this: This doesn’t work. Is there a straightforward way of doing something equivalent? Note that I’m stuck with the class; it’s in a library I can’t rewrite. I’m writing code that takes arguments on the command line, and I would really like it to take symbolic names instead of id