Book Image

PhpStorm Cookbook

By : Mukund Chaudhary
Book Image

PhpStorm Cookbook

By: Mukund Chaudhary

Overview of this book

Table of Contents (16 chapters)
PhpStorm Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Creating a new PHP method


If classes that represent real-world entities are nouns, they do not have any existence without verbs—the actions to be performed. To be able to maximize the technical profit for the manager you work for, you must be ready to use functions for all the verbs that exist in your use case.

Getting ready

Say for example, you have a pizza cooking task at hand. The recipe would consist of a (bare minimum) pizza bread (a noun), cheese (a noun), some salt (a noun). If you ponder over your problem, you will realize that you need to apply cheese to your pizza bread and add salt according to taste. If you look at this scenario from a technical perspective, you would most probably decide that there would be a PizzaDish class with functions such as applyCheese(pizzaBread), addSalt(cheese), and so on.

How to do it...

Creating a method in PhpStorm is easy. Suppose you have your PizzaDish class. Your pizza dish is a Dish so your PizzaDish would extend Dish. Your class would look like...