Scraping PubMed query results: follow-up I recently posted a question looking for feedback on a script I wrote (see: Scraping PubMed query results)

Since then I have re-written it into a class, which I have posted below.  How does it look?  How can I improve upon it?

class PubMedQuery {

private $query;
private $searchParameters;
private $searchURL;
private $fetchParameters;
private $fetchURL;
private $searchResults;
private $fetchResults;
private $matches;
private $matchRegex;
private $emailAddresses;

public function __construct($query) {
    $this-&gt;query = $query;
}

public function setSearchParameters() {
    $this-&gt;searchParameters = array(
        'db'         =&gt; 'pubmed',
        'term'       =&gt; $this-&gt;query,
        'retmode'    =&gt; 'xml',
        'retstart'   =&gt; '0',
        'retmax'     =&gt; '1000',
        'usehistory' =&gt; 'y'
    );
}

public function getSearchParameters() {
    return $this-&gt;searchParameters; 
} 

public function setFetchParameters() {
    $this-&gt;fetchParameters = array(
        'db'        =&gt; 'pubmed',
        'retmax'    =&gt; '1000',
        'query_key' =&gt; (string) $this-&gt;searchResults-&gt;QueryKey,
        'WebEnv'    =&gt; (string) $this-&gt;searchResults-&gt;WebEnv
    );
}

public function getFetchParameters() {
    return $this-&gt;fetchParameters; 
} 

public function setSearchURL() {
    $this-&gt;baseSearchURL = 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?';
    $this-&gt;searchURL = $this-&gt;baseSearchURL . http_build_query($this-&gt;getSearchParameters());
}

public function getSearchURL() {
    return $this-&gt;searchURL; 
}

public function setFetchURL() {
    $this-&gt;baseFetchURL = 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?';
    $this-&gt;fetchURL = $this-&gt;baseFetchURL . http_build_query($this-&gt;getFetchParameters());
}

public function getFetchURL() {
    return $this-&gt;fetchURL; 
}

public function setSearchResults() {
    $this-&gt;setSearchParameters();  
    $this-&gt;setSearchURL();
    $this-&gt;searchResults = simplexml_load_file($this-&gt;getSearchURL());
}

public function getSearchResults() {
    $this-&gt;setFetchParameters();
    $this-&gt;setFetchURL();
    return file_get_contents($this-&gt;getFetchURL()); 
}

public function setEmailAddresses() {
    $this-&gt;matches = array();
    $this-&gt;matchRegex = '/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}/'; 
    preg_match_all($this-&gt;matchRegex, $this-&gt;getSearchResults(), $this-&gt;matches);
    $this-&gt;emailAddresses = array_unique(array_values($this-&gt;matches[0]));
}

public function getEmailAddresses() {
    $this-&gt;setSearchResults();
    $this-&gt;getSearchResults();
    $this-&gt;setEmailAddresses();
    return $this-&gt;emailAddresses;
}
}

//Example using search term "psoriasis"
$query  = new PubMedQuery('psoriasis');
echo implode('&lt;br /&gt;', $query-&gt;getEmailAddresses());
The first thing I might do is get rid of the email regex matching.  PHP has this awesome functionality called filter_var that will take care of a lot of cool things for you, like validating a string as an email address.  This is a better solution because you're less likely to get back false positives where the email is valid, but doesn't match the regex.

Next, I'm not sure I like the search/fetch parameters being set at various places throughout the code.  This feels like something that should be done in the constructor; setup all the data you need to complete the responsibility of the class in the constructor.  If you ever add a new method or make some changes you always have to keep in the back of your mind "Have I set $x yet?".  Well, do it in __construct() and you'll know you have.

Finally, I noticed you were calling some get* functions but not assigning the return value to any variable.  If you don't use the return value you don't need to use the get* function and if you don't use the get* function you don't need it in the class.

Overall I like the API, the method names are fairly self explanatory.  I'm not sure that they should all be public as your use case only has one method actually being used from calling code.  In addition, I might change the properties from private to protected for extensibility but that is certainly not mandatory and is as much a preference as anything else.  I would also prefer to see some kind of documentation, even if it is just the responsibility of the class and your though processes behind why you solved the problem this way.