# \CRemoteImage

Get a image from a remote server using HTTP GET and If-Modified-Since.

## Summary

Methods
Properties
Constants
getStatus()
getDetails()
setCache()
isCacheWritable()
useCache()
setHeaderFields()
save()
updateCacheDetails()
download()
loadCacheDetails()
getCachedSource()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
$saveFolder
$useCache
$http
$status
$defaultMaxAge
$url
$fileName
$fileJson
$cache
N/A

File
  CRemoteImage.php
Package
  Default
Class hierarchy
  \CRemoteImage

## Tags

None found

## Properties

### $saveFolder

    $saveFolder :

Path to cache files.

#### Type

#

## Tags

None found

### $useCache

    $useCache :

Use cache or not.

#### Type

#

## Tags

None found

### $http

    $http :

HTTP object to aid in download file.

#### Type

#

## Tags

None found

### $status

    $status :

Status of the HTTP request.

#### Type

#

## Tags

None found

### $defaultMaxAge

    $defaultMaxAge :

Defalt age for cached items 60*60*24*7.

#### Type

#

## Tags

None found

### $url

    $url :

Url of downloaded item.

#### Type

#

## Tags

None found

### $fileName

    $fileName :

Base name of cache file for downloaded item and name of image.

#### Type

#

## Tags

None found

### $fileJson

    $fileJson :

Filename for json-file with details of cached item.

#### Type

#

## Tags

None found

### $cache

    $cache :

Cache details loaded from file.

#### Type

#

## Tags

None found

## Methods

### getStatus()

    getStatus() : integer

Get status of last HTTP request.

#### Returns

integer —

as status

#

## Tags

None found

### getDetails()

    getDetails() : array

Get JSON details for cache item.

#### Returns

array —

with json details on cache.

#

## Tags

None found

### setCache()

    setCache(  $path) : $this

Set the path to the cache directory.

#### Parameters

| $path |

#### Returns

$this

#

## Tags

None found

### isCacheWritable()

    isCacheWritable() : $this

Check if cache is writable or throw exception.

#### Throws

\Exception

  if cahce folder is not writable.

#### Returns

$this

#

## Tags

None found

### useCache()

    useCache(boolean  $use = true) : $this

Decide if the cache should be used or not before trying to download a remote file.

#### Parameters

boolean | $use | true to use the cache and false to ignore cache.

#### Returns

$this

#

## Tags

None found

### setHeaderFields()

    setHeaderFields() : $this

Set header fields.

#### Returns

$this

#

## Tags

None found

### save()

    save() : string

Save downloaded resource to cache.

#### Returns

string —

as path to saved file or false if not saved.

#

## Tags

None found

### updateCacheDetails()

    updateCacheDetails() : string

Got a 304 and updates cache with new age.

#### Returns

string —

as path to cached file.

#

## Tags

None found

### download()

    download(string  $url) : string

Download a remote file and keep a cache of downloaded files.

#### Parameters

string | $url | a remote url.

#### Throws

\Exception

  when status code does not match 200 or 304.

#### Returns

string —

as path to downloaded file or false if failed.

#

## Tags

None found

### loadCacheDetails()

    loadCacheDetails() : $this

Get the path to the cached image file if the cache is valid.

#### Returns

$this

#

## Tags

None found

### getCachedSource()

    getCachedSource() : string

Get the path to the cached image file if the cache is valid.

#### Returns

string —

as the path ot the image file or false if no cache.

#

## Tags

None found

### CRemoteImage.php