- switch ($format) {
- case 'epub':
- return $this->produceEpub();
-
- case 'mobi':
- return $this->produceMobi();
-
- case 'pdf':
- return $this->producePDF();
-
- case 'csv':
- return $this->produceCSV();
-
- case 'json':
- return $this->produceJSON();
-
- case 'xml':
- return $this->produceXML();
- case 'txt':
- return $this->produceTXT();
+ $functionName = 'produce'.ucfirst($format);
+ if (method_exists($this, $functionName)) {
+ return $this->$functionName();