/Library/Sighhat/Geocode/Transport/Engine/Fopen.php
PHP | 31 lines | 29 code | 2 blank | 0 comment | 2 complexity | 92b1a30450e548c66e8edfc648ba539c MD5 | raw file
- <?php
- namespace Sighhat\Geocode\Transport\Engine
- {
- class Fopen extends Base
- {
- protected $_socket;
- protected $_return;
-
- public function _performStartupCheck()
- {
- if(!(boolean)ini_get('allow_url_fopen'))
- {
- throw new \Sighhat\Exception('Fopen stream wrapper isnt enabled!');
- }
- }
-
- public function connect($url)
- {
- $context = stream_context_create(array(
- 'http'=> array(
- 'method' => 'GET',
- 'timeout' => 3 //timeout so we don't cause unforseen consequences, Gordon.
- )
- ));
- if(!$this->_return = file_get_contents($url, false, $context))
- {
- throw new \Sighhat\Exception('Unable to get geocode');
- }
- }
- }
- }