title: Laravel - enum like variable?
body: <p>I would like to be able to pass enums to functions. I know PHP doesn't support them per se, but there are instances where an enum would make sense.</p>
  
  <p>For instance, take:
  <code>function doPayment($payment_method = 'paypal') 
  { // ... code goes here }
  </code></p>
  
  <p>You can call it via <code>doPayment('paypal'), doPayment(),  doPayment('creditcard'),</code> or <code>doPayment('creditcadr');</code></p>
  
  <p>This introduces the chance of typos plus it's a pain to keep strings consistent and to debug. We could pass them as ints such as doPayment(2) but that's ugly and we'd have to keep track of them or put them in defines, which is the next example: doPayment(PAYMENT_METHOD_PAYPAL); but then we'd have to put the define in some global file that is accessible by all. Also I find that you end up with a class of hundreds of defines and it's hard to keep track of what belongs to what. </p>
  
  <p>Meanwhile in Java, it's easy:</p>
  
  <pre><code>doPayment(PaymentClass.PaymentMethod.PayPal); // or doPayment(PaymentMethod.PayPal);
  </code></pre>
  
  <p>That's really what I'm looking for if possible. I guess I could create an external class for each set of enums but that adds a lot of files as well (while the Java example you can create an enum within the parent class).</p>
  
  <p>I was wondering if Laravel has added a method to do this, if it's not doable in PHP.</p>