aboutsummaryrefslogtreecommitdiff
path: root/lib/Favicon/DataAccess.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2017-04-23 14:06:37 +0200
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2017-04-23 14:06:37 +0200
commit44c9ae51c44478e56ee70ce692ade6a275981320 (patch)
treeed47cd59439b9f826108886cdb0dfe30f113fbb6 /lib/Favicon/DataAccess.php
parent6d5fb27f978c25be09a939d0f426a5c8962e79ec (diff)
Rewriten Favicon library using cURL
Reduce the number of requests, more robust, many more cases working, reduced code
Diffstat (limited to 'lib/Favicon/DataAccess.php')
-rw-r--r--lib/Favicon/DataAccess.php43
1 files changed, 0 insertions, 43 deletions
diff --git a/lib/Favicon/DataAccess.php b/lib/Favicon/DataAccess.php
deleted file mode 100644
index 1445e9343..000000000
--- a/lib/Favicon/DataAccess.php
+++ /dev/null
@@ -1,43 +0,0 @@
-<?php
-
-namespace Favicon;
-
-/**
- * DataAccess is a wrapper used to read/write data locally or remotly
- * Aside from SOLID principles, this wrapper is also useful to mock remote resources in unit tests
- * Note: remote access warning are silenced because we don't care if a website is unreachable
- **/
-class DataAccess {
- public function retrieveUrl($url) {
- $this->set_context();
- return @file_get_contents($url);
- }
-
- public function retrieveHeader($url) {
- $this->set_context();
- $headers = @get_headers($url, 1);
- return is_array($headers) ? array_change_key_case($headers) : array();
- }
-
- public function saveCache($file, $data) {
- file_put_contents($file, $data);
- }
-
- public function readCache($file) {
- return file_get_contents($file);
- }
-
- private function set_context() {
- stream_context_set_default(
- array(
- 'http' => array(
- 'method' => 'GET',
- 'follow_location' => 0,
- 'max_redirects' => 1,
- 'timeout' => 10,
- 'header' => "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:20.0; Favicon; +https://github.com/ArthurHoaro/favicon) Gecko/20100101 Firefox/32.0\r\n",
- )
- )
- );
- }
-} \ No newline at end of file