Good question, Afridy.
Sticking with your example, there are some other things you should recognise and attempt to address.
Your code is that it mostly only considers the “happy path”
It seems not to check:
-The number follows a valid pattern, is well formed.
-Depending on the country it might HAVE to conform to 04xxxxxxx or 07xxxxxxxxxxxx
-What happens if no number is accidentally passed to it.
It does not seem to be something you could use in a variety of projects, which:
-Use a different SMS gateway.
-Provide different credentials.
So, it is not very “re-usable” and neither is it very “smart”, you cannot think of it being a discrete, self-contained module to which you can delegate responsibility for doing a task.
I’m skimming over many other issues for the sake of brevity, but essentially jumping from thinking as you are now, to thinking about telling some piece of code to “Here is what you need, now just go away please and get on with this job, thats why I pay you.”
Your target might be to end up with userland code as simple as this.
$sms = new ClickatellTexter($number);
$sms->send($msg);
Knowing that ClickatellTexter will go away, maybe find its own credentials (which may be kept centrally elsewhere), do something predictable if either number is missing or if msg is empty and either report back or log something or just die quietly if it fails.
Then, with the same core code which ClickatellTexter relies upon, elsewhere in your universe - someone else - or maybe you in 6 months time can go, right, now I need a BulksmsTexter and then create a simple concrete class where the only difference between the concrete BulksmsTexter and ClickatellTexter is this line:
$url="http://api.clickatell.com/http/sendmsg?user=xxx&password=xxx .. etc";
But then decide to use it in a slightly different way:
$sms = new BulksmsTexter($number);
$sms->setCountry('UK');
$sms->setLogging('myfile.txt');
$sms->send($msg);
… so both classes are simply part of a small network of other tiny classes that are designed to operate with each other in a robust fashion.
That scenario is too outlandish and will never happen to me? Read this, how will you respond if Clickatell goes down or if a client wants to use another gateway? Copy and paste your existing class? Nope, that’s not the idea.
Buying a good OOP book which explains some of the basic principles of OOP should be on your horizon as soon as you get the syntax sorted out - but there are plenty of threads on here recommending books.
HTH