for my new job I have to learn PHP, and so far I'm finding it quite frustrating (I'm used to desktop languages, like C#, Java, etc.).
I'm kind of teaching myself the language, and just creating little projects at a time.
Right now I have three classes:
Customer
DateOfBirth
Address
In the Customer class, I have getter and setter methods. For the setter methods, I'd like to check the type of a parameter.
For example: (pseudo):
func set_address($address)
if $address typeof Addess then
this->address = $address
else then
throw ArgumentException("Invalid parameter!");
end
end
I hope you get what I mean. I just want things to be right and not get used to doing stupid things.
I hope you can help! Cheers in advance!
if ($address instanceof Address) $this->$m_address = $address;
– SimonC May 21 '15 at 13:31