Skip to content

Add Enum constants to resource classes #516

@willselby

Description

@willselby

Would it be possible to have the relevant enum values added as constants to the resource classes please?

Similar to what Stripe has;
https://github.com/stripe/stripe-php/blob/0aa6a385e66ffe7e095372737d8afe491a94e015/lib/Invoice.php#L130

This saves us having to do string comparisons when we want to check the value of a property.
e.g.
if ($invoice->state === 'paid') becomes if ($invoice->state === \Recurly\Resources\Invoice::STATE_PAID)

  • if the value is ever changed we don't need to update string comparisons in multiple places.
  • IDE can flag that the constant doesn't exist if one is removed or mis-typed.

I'd be happy to open a PR, but your contribution guidelines clearly state that you won't accept any PR's that modify resource files.

Thank you.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions