How do I read source code that eventually leads back to an interface?

Posted 4 months ago by ryanmortier

Whenever I'm trying to figure out how something works and it leads back to an interface, I get lost.

For example, I was trying to figure out how the Str::plural() method works and if it supported non-Americanized English.

Step 1: Look up the Illuminate\Support\Str class. Done:

Step 2: Find the plural() method. Done:

Step 3: See that it's using a Pluralizer class so find that. Done:

Step 4: Find the plural() method on the Pluralizer class. Done:

Step 5: See that it's using Doctrine's Inflector class so find that. Done:

Step 6: Find the pluralize() method on the Inflector class. Done:

Step 7: See that it's calling an inflect() method on a pluralizer object so try to find what the pluralizer object is. Done: It appears to be some type of instance of a WordInflector interface.

Now how do I go from here? I have no idea what the object is being passed that implements the WordInflector interface.

Please sign in or create an account to participate in this conversation.