I am starting to use namespaces, but I'm having a difficult time understanding when to use them.
- I want to group "helper methods"
- I don't expect to extend this group (not really a class)
- I think I want to change a variable instance
Here's an example of the situation I have:
$date = ''; // variable to be used in all methods
function get_sports_data() {
get_sports_data_yahoo();
get_sports_data_google();
get_sports_data_bing();
}
function get_sports_data_yahoo() {} // uses $date
function get_sports_data_google() {} // uses $date
function get_sports_data_bing() {} // uses $date
I don't expect to use the helper functions individually.
- Would it best to use a namespace called
get_sports_datawith methods for yahoo, google, and bing? - Would it be correct to set the date as an instance of an object or would it be better to pass the variable through each method?
I asked the PHP chat, but I think they were busy.
get_sports_data($filter=null), and$filter="yahoo"/etc ?