PageRenderTime 41ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/Library/Sighhat/Geocode/Transport/Engine/Fopen.php

https://github.com/sketchmedia/sketchguild
PHP | 31 lines | 29 code | 2 blank | 0 comment | 2 complexity | 92b1a30450e548c66e8edfc648ba539c MD5 | raw file
  1. <?php
  2. namespace Sighhat\Geocode\Transport\Engine
  3. {
  4. class Fopen extends Base
  5. {
  6. protected $_socket;
  7. protected $_return;
  8. public function _performStartupCheck()
  9. {
  10. if(!(boolean)ini_get('allow_url_fopen'))
  11. {
  12. throw new \Sighhat\Exception('Fopen stream wrapper isnt enabled!');
  13. }
  14. }
  15. public function connect($url)
  16. {
  17. $context = stream_context_create(array(
  18. 'http'=> array(
  19. 'method' => 'GET',
  20. 'timeout' => 3 //timeout so we don't cause unforseen consequences, Gordon.
  21. )
  22. ));
  23. if(!$this->_return = file_get_contents($url, false, $context))
  24. {
  25. throw new \Sighhat\Exception('Unable to get geocode');
  26. }
  27. }
  28. }
  29. }