APA-style titles in Laravel
APA-style titles are a specific type of title case that is used in academic papers, research reports, and journal articles. It’s a style that’s used by the American Psychological Association (APA) and is a variation of the title case.
For instance, the title “The quick brown fox jumps over the lazy dog” would be written as “The Quick Brown Fox Jumps Over The Lazy Dog” in the title case. But in APA style, it would be written as “The Quick Brown Fox Jumps Over the Lazy Dog”.
As you can notice, the only difference between the title case and APA-style is that the articles (a, an, the) are not capitalized in APA-style. That’s because the articles are not considered as important as the other words in the title.
Apart from the articles, the APA-style also doesn’t capitalize the coordinating conjunctions (and, but, for, nor, or, so, yet) and prepositions (e.g. in, on, of, to, with, etc.) that are less than five letters long.
So, recently, Laravel has been shipped with a brand new APA-style title helper which you can use to convert your titles to APA-style.
Here’s how you can use it.
use Illuminate\Support\Str;
echo Str::apa('The quick brown fox jumps over the lazy dog');
// The Quick Brown Fox Jumps Over the Lazy Dog
echo Str::apa('back to the future');
// Back to the Future
echo Str::apa('SELF-REPORT');
// Self-Report
As you can tell, the helper is pretty smart and can handle a lot of different cases. It can even handle the hyphenated words and acronyms. I think it’s a pretty neat addition to the framework for the projects that use APA-style titles.
Like this article?
Buy me a coffee👋 Hi there! I'm Amit. I write articles about all things web development. You can become a sponsor on my blog to help me continue my writing journey and get your brand in front of thousands of eyes.