/** * Retrieve an array of social network status updates. * * @return array */ public function getArray() { // No instantiationinginging! // --------------------------------------------------- // This time we don't need to create a new instance of // our TwitterFeedReader object. Instead we can use // the instance that has been injected through the // constructor of the class. // // So, we are now using dependency injection. Job done, // right? Better take a look at the tests. return $this->twitterFeedReader->getMessages(); }
/** * Retrieve an array of social network status updates. * * @return array */ public function getArray() { // These classes had a breakup :( // --------------------------------------------------- // The tight coupling between our status retrieval class // and our Twitter API class has been loosened. Each class // now has its own single responsibility. $twitterFeedReader = new TwitterFeedReader(); return $twitterFeedReader->getMessages(); }
/** * Retrieve an array of social network status updates. * * @return array */ public function getArray() { return $this->twitterFeedReader->getMessages(); }