/** * get information about a given set of stock quotes * @param string $symbols single or multiple symbols seperate by commas * @return array */ public function getInfo($symbols = '') { // convert symbols into array format $symbols = $this->validateSymbols($symbols); // get the vendor object defined in $this->apiConfig to pass into QuotesVendor $vendor = $this->quotesVendorFactory(); $quotes = new QuotesVendor($vendor); return $quotes->getQuote($symbols); }
public function testGetQuote() { // get the default vendor class defined in the config file $config = Config::get('financeApi'); $default = $config['defaultQuotesVendor']; $vendor = $config['quotesVendors'][$default]; $quotes = new QuotesVendor(new $vendor()); $data = $quotes->getQuote(array('aapl', 'mcd')); // confirm the $data is of length 2 and first quote is for AAPL $this->assertTrue(count($data) === 2 && isset($data[0]['symbol']) && $data[0]['symbol'] === 'AAPL'); }