<?php

App::uses('Component', 'Controller');
require(APP. 'Plugin' .DS. 'Provider' .DS. 'Controller' .DS. 'Component' .DS. 'KTelecom.php');

/**
 * Plugin de validacao de saldos por conta
 *
 * PHP versions 5+
 *
 * @author	 	  Fabricio S Costa
 * @link          https://fabriciojf@gmail.com 
 * @version		  1.0
 * 
 * O outro componente que seu componente utiliza
 * public $components = array('Outro');
 */
class ProviderComponent extends Component {
	
	// public $components = array('Provider.Ktelecom');

	/**
	 * Executa a consulta no provedor 
	 */
	public function execute($phone) {		
		return $this->execKTelecom($phone);
	}
	
	/**
	 * Executa a consulta no kingtelecom
	 */
	public function execKTelecom($phone) {
		$KTelecom = new KTelecom();
		$url = $KTelecom::conf('url') . $phone;
		$_result = file_get_contents($url);
		return substr($_result, 3, 2);
	}
	
}