ShortUrl Class Reference

Inheritance diagram for ShortUrl:
RedBeanModel BeanModel ObservableComponent ShortUrlForTest

Public Member Functions

 onCreated ()

Static Public Member Functions

static getDefaultMetadata ()
static resolveHashByUrl ($url)
static getHashByUrl ($url)
static getUrlByHash ($hash)
static deleteOld ()

Data Fields

const ALLOWED_CHARS = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
const HASH_LENGTH = 10
const LIFE_TIME_IN_DAYS = 100

Static Protected Member Functions

static getRandomHash ()

Detailed Description

Definition at line 37 of file ShortUrl.php.


Member Function Documentation

onCreated (  ) 

Called on construction when a new model is created.

Reimplemented from RedBeanModel.

Reimplemented in ShortUrlForTest.

Definition at line 45 of file ShortUrl.php.

static getDefaultMetadata (  )  [static]

Returns the default meta data for the class. It must be appended to the meta data from the parent model, if any.

Reimplemented from RedBeanModel.

Definition at line 50 of file ShortUrl.php.

static resolveHashByUrl ( url  )  [static]

This resolves the hash by url, if url is not already saved it creates a new ShortUrl model and saves the hash/url pair

Parameters:
string $url
Returns:
string

Definition at line 82 of file ShortUrl.php.

static getHashByUrl ( url  )  [static]

Given an url get the stored hash or trows exception if it does not exists

Parameters:
string $url
Returns:
string
Exceptions:
NotFoundException 

Definition at line 119 of file ShortUrl.php.

static getUrlByHash ( hash  )  [static]

Given an hash return the stored url or throws exception if hash does not exists

Parameters:
string $hash
Returns:
string
Exceptions:
NotFoundException 

Definition at line 144 of file ShortUrl.php.

static getRandomHash (  )  [static, protected]

Crete a random hash based

Returns:
string

Definition at line 166 of file ShortUrl.php.

static deleteOld (  )  [static]

Deletes all the old ShortUrls

Definition at line 181 of file ShortUrl.php.


The documentation for this class was generated from the following file:
 All Data Structures Functions Variables
Generated on Mon Mar 27 07:10:29 2017