public function humanDiff(int $from, int $to = null, string $format = ''): string
    {
        $to   = $to ?? time();
        $diff = (int) abs($to - $from);

        if ($format !== 'abbrev' && $format !== 'default') {
            $format = 'default'; // Must be valid.
        }
        if ($diff < $this::SECONDS_IN_MINUTE) {
            $diff            = max(1, $diff);
            $fmat['abbrev']  = ['%1$ss', '%1$ss'];
            $fmat['default'] = ['%1$s sec', '%1$s secs'];
        } elseif ($diff < $this::SECONDS_IN_HOUR) {
            $diff            = max(1, round($diff / $this::SECONDS_IN_MINUTE));
            $fmat['abbrev']  = ['%1$sm', '%1$sm'];
            $fmat['default'] = ['%1$s min', '%1$s mins'];
        } elseif ($diff < $this::SECONDS_IN_DAY) {
            $diff            = max(1, round($diff / $this::SECONDS_IN_HOUR));
            $fmat['abbrev']  = ['%1$sh', '%1$sh'];
            $fmat['default'] = ['%1$s hour', '%1$s hours'];
        } elseif ($diff < $this::SECONDS_IN_WEEK) {
            $diff            = max(1, round($diff / $this::SECONDS_IN_DAY));
            $fmat['abbrev']  = ['%1$sd', '%1$sd'];
            $fmat['default'] = ['%1$s day', '%1$s days'];
        } elseif ($diff < $this::SECONDS_IN_WEEK * 4) {
            $diff            = max(1, round($diff / $this::SECONDS_IN_WEEK));
            $fmat['abbrev']  = ['%1$sw', '%1$sw'];
            $fmat['default'] = ['%1$s week', '%1$s weeks'];
        } elseif ($diff < $this::SECONDS_IN_YEAR) {
            $diff            = max(1, round($diff / ($this::SECONDS_IN_WEEK * 4)));
            $fmat['abbrev']  = ['%1$smo', '%1$smo'];
            $fmat['default'] = ['%1$s month', '%1$s months'];
        } else {
            $diff            = max(1, round($diff / $this::SECONDS_IN_YEAR));
            $fmat['abbrev']  = ['%1$sy', '%1$sy'];
            $fmat['default'] = ['%1$s year', '%1$s years'];
        }
        return sprintf(_n($fmat[$format][0], $fmat[$format][1], $diff), $diff);
    }

public
function
humanDiff
(
int
$
from
,
int
$
to
=
,
string
$
format
=
''
)
:
string
{
$
to
=
$
to
??
time
(
)
;
$
diff
=
(
int
)
abs
(
$
to
$
from
)
;
if
(
$
format
!==
'abbrev'
&&
$
format
!==
'default'
)
{
$
format
=
'default'
;
// Must be valid.
}
if
(
$
diff
<
$
this
::
SECONDS_IN_MINUTE
)
{
$
diff
=
max
(
1
,
$
diff
)
;
$
fmat
[
'abbrev'
]
=
[
'%1$ss'
,
'%1$ss'
]
;
$
fmat
[
'default'
]
=
[
'%1$s sec'
,
'%1$s secs'
]
;
}
elseif
(
$
diff
<
$
this
::
SECONDS_IN_HOUR
)
{
$
diff
=
max
(
1
,
round
(
$
diff
/
$
this
::
SECONDS_IN_MINUTE
)
)
;
$
fmat
[
'abbrev'
]
=
[
'%1$sm'
,
'%1$sm'
]
;
$
fmat
[
'default'
]
=
[
'%1$s min'
,
'%1$s mins'
]
;
}
elseif
(
$
diff
<
$
this
::
SECONDS_IN_DAY
)
{
$
diff
=
max
(
1
,
round
(
$
diff
/
$
this
::
SECONDS_IN_HOUR
)
)
;
$
fmat
[
'abbrev'
]
=
[
'%1$sh'
,
'%1$sh'
]
;
$
fmat
[
'default'
]
=
[
'%1$s hour'
,
'%1$s hours'
]
;
}
elseif
(
$
diff
<
$
this
::
SECONDS_IN_WEEK
)
{
$
diff
=
max
(
1
,
round
(
$
diff
/
$
this
::
SECONDS_IN_DAY
)
)
;
$
fmat
[
'abbrev'
]
=
[
'%1$sd'
,
'%1$sd'
]
;
$
fmat
[
'default'
]
=
[
'%1$s day'
,
'%1$s days'
]
;
}
elseif
(
$
diff
<
$
this
::
SECONDS_IN_WEEK
*
4
)
{
$
diff
=
max
(
1
,
round
(
$
diff
/
$
this
::
SECONDS_IN_WEEK
)
)
;
$
fmat
[
'abbrev'
]
=
[
'%1$sw'
,
'%1$sw'
]
;
$
fmat
[
'default'
]
=
[
'%1$s week'
,
'%1$s weeks'
]
;
}
elseif
(
$
diff
<
$
this
::
SECONDS_IN_YEAR
)
{
$
diff
=
max
(
1
,
round
(
$
diff
/
(
$
this
::
SECONDS_IN_WEEK
*
4
)
)
)
;
$
fmat
[
'abbrev'
]
=
[
'%1$smo'
,
'%1$smo'
]
;
$
fmat
[
'default'
]
=
[
'%1$s month'
,
'%1$s months'
]
;
}
else
{
$
diff
=
max
(
1
,
round
(
$
diff
/
$
this
::
SECONDS_IN_YEAR
)
)
;
$
fmat
[
'abbrev'
]
=
[
'%1$sy'
,
'%1$sy'
]
;
$
fmat
[
'default'
]
=
[
'%1$s year'
,
'%1$s years'
]
;
}
return
sprintf
(
_n
(
$
fmat
[
$
format
]
[
0
]
,
$
fmat
[
$
format
]
[
1
]
,
$
diff
)
,
$
diff
)
;
}

Human time difference.

@since 170124.74961 Initial release.

@param int      $from   From time.
@param int|null $to     Defaults to current time.
@param string   $format Formatting option.

@return string Human time difference.


public function getItems(array $keys)
    {
        $result = array();

        foreach ($keys as $key) {
            $result[$key] = $this->getItem($key);
        }

        return $result;
    }

public function getItems ( array $ keys ) { $ result = array ( ) ; foreach ( $ keys as $ key ) { $ result [ $ key ] = $ this -> getItem ( $ key ) ; } return $ result ; }

Returns a traversable set of cache items.

@param array $keys
An indexed array of keys of items to retrieve.
@return \Traversable
A traversable collection of Cache Items in the same order as the $keys
parameter, keyed by the cache keys of each item. If no items are found
an empty Traversable collection will be returned.

Returns a traversable set of cache items .


public function render(Marker $marker, Map $map = null)
    {
        $this->jsonBuilder
            ->reset()
            ->setValue('[position]', $marker->getPosition()->getJavascriptVariable(), false);

        if ($map !== null) {
            $this->jsonBuilder->setValue('[map]', $map->getJavascriptVariable(), false);
        }

        if ($marker->hasAnimation()) {
            $this->jsonBuilder->setValue('[animation]', $this->animationHelper->render($marker->getAnimation()), false);
        }

        if ($marker->hasIcon()) {
            $this->jsonBuilder->setValue('[icon]', $marker->getIcon()->getJavascriptVariable(), false);
        }

        if ($marker->hasShadow()) {
            $this->jsonBuilder->setValue('[shadow]', $marker->getShadow()->getJavascriptVariable(), false);
        }

        if ($marker->hasShape()) {
            $this->jsonBuilder->setValue('[shape]', $marker->getShape()->getJavascriptVariable(), false);
        }

        $this->jsonBuilder->setValues($marker->getOptions());

        return sprintf(
            '%s = new google.maps.Marker(%s);'.PHP_EOL,
            $marker->getJavascriptVariable(),
            $this->jsonBuilder->build()
        );
    }

public
function
render
(
Marker
$
marker
,
Map
$
map
=
)
{
$
this
->
jsonBuilder
->
reset
(
)
->
setValue
(
'[position]'
,
$
marker
->
getPosition
(
)
->
getJavascriptVariable
(
)
,
false
)
;
if
(
$
map
!==
)
{
$
this
->
jsonBuilder
->
setValue
(
'[map]'
,
$
map
->
getJavascriptVariable
(
)
,
false
)
;
}
if
(
$
marker
->
hasAnimation
(
)
)
{
$
this
->
jsonBuilder
->
setValue
(
'[animation]'
,
$
this
->
animationHelper
->
render
(
$
marker
->
getAnimation
(
)
)
,
false
)
;
}
if
(
$
marker
->
hasIcon
(
)
)
{
$
this
->
jsonBuilder
->
setValue
(
'[icon]'
,
$
marker
->
getIcon
(
)
->
getJavascriptVariable
(
)
,
false
)
;
}
if
(
$
marker
->
hasShadow
(
)
)
{
$
this
->
jsonBuilder
->
setValue
(
'[shadow]'
,
$
marker
->
getShadow
(
)
->
getJavascriptVariable
(
)
,
false
)
;
}
if
(
$
marker
->
hasShape
(
)
)
{
$
this
->
jsonBuilder
->
setValue
(
'[shape]'
,
$
marker
->
getShape
(
)
->
getJavascriptVariable
(
)
,
false
)
;
}
$
this
->
jsonBuilder
->
setValues
(
$
marker
->
getOptions
(
)
)
;
return
sprintf
(
'%s = new google.maps.Marker(%s);'
.
PHP_EOL
,
$
marker
->
getJavascriptVariable
(
)
,
$
this
->
jsonBuilder
->
build
(
)
)
;
}

Renders a marker.

@param Ivory\GoogleMap\Overlays\Marker $marker The marker.
@param Ivory\GoogleMap\Map             $map    The map.

@return string The JS output.


public function build($build=false)
    {
        if($build){
            header('Content-Type: application/json');
            echo json_encode($this->json);
            return true;
        }

        return json_encode($this->json);
    }

public
function
build
(
$
build
=
false
)
{
if
(
$
build
)
{
header
(
'Content-Type: application/json'
)
;
echo
json_encode
(
$
this
->
json
)
;
return
true
;
}
return
json_encode
(
$
this
->
json
)
;
}

Build json for Bulutfonxm

@param bool $build
@return bool|string


public function render(MarkerShape $markerShape)
    {
        return sprintf(
            '%s = new google.maps.MarkerShape(%s);'.PHP_EOL,
            $markerShape->getJavascriptVariable(),
            json_encode(array('type' => $markerShape->getType(), 'coords' => $markerShape->getCoordinates()))
        );
    }

public
function
render
(
MarkerShape
$
markerShape
)
{
return
sprintf
(
'%s = new google.maps.MarkerShape(%s);'
.
PHP_EOL
,
$
markerShape
->
getJavascriptVariable
(
)
,
json_encode
(
array
(
'type'
=>
$
markerShape
->
getType
(
)
,
'coords'
=>
$
markerShape
->
getCoordinates
(
)
)
)
)
;
}

Renders a marker shape.

@param \Ivory\GoogleMap\Overlays\MarkerShape $markerShape The marker shape.

@return string The JS output.


public function render($scaleControlStyle)
    {
        switch ($scaleControlStyle) {
            case ScaleControlStyle::DEFAULT_:
                return sprintf('google.maps.ScaleControlStyle.%s', strtoupper($scaleControlStyle));
            default:
                throw HelperException::invalidScaleControlStyle();
        }
    }

public function render ( $ scaleControlStyle ) { switch ( $ scaleControlStyle ) { case ScaleControlStyle :: DEFAULT_ : return sprintf ( 'google.maps.ScaleControlStyle.%s' , strtoupper ( $ scaleControlStyle ) ) ; default : throw HelperException :: invalidScaleControlStyle ( ) ; } }

Renders a scale control style.

@param string $scaleControlStyle The scale control style.

@throws \Ivory\GoogleMap\Exception\HelperException If the scale control style is not valid.

@return string The JS output.


public function isValid(string $slug, bool $strict = true): bool
    {
        return (bool) preg_match($strict ? $this::SLUG_STRICT_REGEX_VALID : $this::SLUG_REGEX_VALID, $slug);
    }

public function isValid ( string $ slug , bool $ strict = true ) : bool { return ( bool ) preg_match ( $ strict ? $ this :: SLUG_STRICT_REGEX_VALID : $ this :: SLUG_REGEX_VALID , $ slug ) ; }

Validate slug.

@since 150424 Initial release.

@param string $slug   Slug.
@param bool   $strict Strict?

@return bool True if slug is valid.


public function isReserved(string $slug): bool
    {
        $slug = mb_strtolower($slug);
        $slug = str_replace(['-', '_', '.'], '', $slug);

        if (($is = &$this->cacheKey(__FUNCTION__, $slug)) !== null) {
            return $is; // Cached this already.
        }
        if (mb_strlen($slug) < 3) {
            return $is = true;
        } elseif (in_array($slug, $this::SLUG_RESERVED_STRINGS, true)) {
            return $is = true;
        }
        foreach ($this::SLUG_RESERVED_REGEX_FRAGS as $_regex_frag) {
            if (preg_match('/^'.$_regex_frag.'$/ui', $slug)) {
                return $is = true;
            }
        } // unset($_regex_frag); // Housekeeping.

        return $is = false;
    }

Is slug reserved?

@since 150424 Reserved slugs.

@param string $slug Slug.

@return bool True if slug is reserved.


public function toName(string $slug): string
    {
        $name = $slug; // Initialize.
        $name = preg_replace('/[^\p{L}\p{N}]+/u', ' ', $name);
        $name = $this->c::mbUcWords($name);
        $name = $this->c::mbTrim($name);

        return $name;
    }

public
function
toName
(
string
$
slug
)
:
string
{
$
name
=
$
slug
;
// Initialize.
$
name
=
preg_replace
(
'/[^\p{L}\p{N}]+/u'
,
' '
,
$
name
)
;
$
name
=
$
this
->
c
::
mbUcWords
(
$
name
)
;
$
name
=
$
this
->
c
::
mbTrim
(
$
name
)
;
return
$
name
;
}

Convert slug to name.

@since 150424 Initial release.

@param string $slug Slug.

@return string Name; based on slug.


public function toVar(string $slug, bool $strict = true): string
    {
        $var = $slug; // Initialize.
        $var = mb_strtolower($this->c::forceAscii($var));
        $var = preg_replace('/[^a-z0-9]+/u', '_', $var);
        $var = $this->c::mbTrim($var, '', '_');

        if ($strict && $var && !preg_match('/^[a-z]/u', $var)) {
            $var = 'x'.$var; // Force `^[a-z]`.
        }
        return $var;
    }

public
function
toVar
(
string
$
slug
,
bool
$
strict
=
true
)
:
string
{
$
var
=
$
slug
;
// Initialize.
$
var
=
mb_strtolower
(
$
this
->
c
::
forceAscii
(
$
var
)
)
;
$
var
=
preg_replace
(
'/[^a-z0-9]+/u'
,
'_'
,
$
var
)
;
$
var
=
$
this
->
c
::
mbTrim
(
$
var
,
''
,
'_'
)
;
if
(
$
strict
&&
$
var
&&
!
preg_match
(
'/^[a-z]/u'
,
$
var
)
)
{
$
var
=
'x'
.
$
var
;
// Force `^[a-z]`.
}
return
$
var
;
}

Convert slug to var.

@since 160220 Initial release.

@param string $slug   Slug.
@param bool   $strict Strict?

@return string Var; based on slug.


public function setCoordinates($coordinates)
    {
        $this->coordinates = array();

        foreach ($coordinates as $coordinate) {
            $this->addCoordinate($coordinate);
        }
    }

public function setCoordinates ( $ coordinates ) { $ this -> coordinates = array ( ) ; foreach ( $ coordinates as $ coordinate ) { $ this -> addCoordinate ( $ coordinate ) ; } }

Sets the polyline coordinates.

@param array $coordinates The polyline coordinates.


public function store()
    {
        if (empty($cacheFile = $this->cacheFile())) {
            return;
        }
        file_put_contents(
            base_path($cacheFile),
            json_encode($this->all()->toArray(), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)
        );
    }

public function store ( ) { if ( empty ( $ cacheFile = $ this -> cacheFile ( ) ) ) { return ; } file_put_contents ( base_path ( $ cacheFile ) , json_encode ( $ this -> all ( ) -> toArray ( ) , JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES ) ) ; }


public function all(): Repository
    {
        if ($this->repository === null && !$this->restore()) {
            $this->repository = new Repository();
            $this->scan();
        }

        return $this->repository;
    }

public function all ( ) : Repository { if ( $ this -> repository === null && ! $ this -> restore ( ) ) { $ this -> repository = new Repository ( ) ; $ this -> scan ( ) ; } return $ this -> repository ; }


public function parse(array $vars = []): string
    {
        ++$this->parsed; // Parsing now.

        if ($this->ext === 'php') {
            $_this = $this; // `$this` in symbol table.
            // ↑ Strange magic makes it possible for `$this` to be used from
            // inside the template file also. We just need to reference it here.
            // See: <http://stackoverflow.com/a/4994799/1219741>

            unset($_this, $vars['this']); // Avoid conflicts.
            $this->vars = $vars; // Set current template variables.
            unset($vars); // Don't include as a part of template variables.

            extract($this->vars); // Extract for template.

            ob_start(); // Output buffer.
            require $this->dir.'/'.$this->file;
            return ob_get_clean();
        } else {
            return file_get_contents($this->dir.'/'.$this->file);
        }
    }

Parse template.

@since 150424 Initial release.

@param array $vars Template vars.

@return string Parsed template contents.


protected function setVars(array $defaults, array ...$vars): array
    {
        return $this->vars = array_replace_recursive($defaults, $this->vars, ...$vars);
    }

protected function setVars ( array $ defaults , array ... $ vars ) : array { return $ this -> vars = array_replace_recursive ( $ defaults , $ this -> vars , ... $ vars ) ; }

Set template vars.

@since 150424 Initial release.

@param array $defaults Default vars.
@param array ...$vars Variadic template vars.

@return array New template vars.


protected function hasParent(string $file = null): bool
    {
        if (isset($file)) {
            return in_array($file, $this->parents, true);
        }
        return !empty($this->parents);
    }

protected function hasParent ( string $ file = null ) : bool { if ( isset ( $ file ) ) { return in_array ( $ file , $ this -> parents , true ) ; } return ! empty ( $ this -> parents ) ; }

Has a parent?

@since 150424 Initial release.

@param string|null $file Template file.

@return bool True if child has a parent.


protected function parentVars(string $file = null): array
    {
        if (isset($file)) {
            return $this->parent_vars[$file] ?? [];
        }
        $closest_ancestor_vars = end($this->parent_vars);
        return $parent_vars    = $closest_ancestor_vars ?: [];
    }

protected function parentVars ( string $ file = null ) : array { if ( isset ( $ file ) ) { return $ this -> parent_vars [ $ file ] ?? [ ] ; } $ closest_ancestor_vars = end ( $ this -> parent_vars ) ; return $ parent_vars = $ closest_ancestor_vars ? : [ ] ; }

Parent template vars.

@since 150424 Initial release.

@param string|null $file Template file.

@return array Parent template vars.


protected function get(string $new_child_file, array $new_child_vars = [], string $new_child_dir = ''): string
    {
        $new_child_parents     = array_merge($this->parents, [$this->file]);
        $new_child_parent_vars = array_merge($this->parent_vars, [$this->file => &$this->vars]);
        $new_child_Template    = $this->c::getTemplate($new_child_file, $new_child_dir, [
            'parents'     => $new_child_parents,
            'parent_vars' => $new_child_parent_vars,
            'Route'       => $this->Route,
        ]);
        // Variables from the closest ancestors take precedence over further/older ancestors.
        // File-specific variables in those ancestors take precedence over those that aren't file-specific.

        foreach (array_reverse($new_child_parent_vars, true) as $_parent_file => $_parent_vars) {
            if (isset($_parent_vars[$new_child_file]) && is_array($_parent_vars[$new_child_file])) {
                $new_child_vars = array_replace_recursive($_parent_vars[$new_child_file], $new_child_vars);
            }
            $_parent_vars_not_file_specific = array_diff_key($_parent_vars, $new_child_parent_vars + [$new_child_file => 0]);
            $new_child_vars                 = array_replace_recursive($_parent_vars_not_file_specific, $new_child_vars);
        } // unset($_parent_file, $_parent_vars, $_parent_vars_not_file_specific); // Housekeeping.

        return $new_child_Template->parse($new_child_vars);
    }

Get a child template.

@since 150424 Initial release.

@param string $new_child_file Relative to templates dir.
@param array  $new_child_vars Template vars for the include.
@param string $new_child_dir  From a specific directory?

@return string Parsed template contents for child template.


protected function getOptions()
    {
        $options = parent::getOptions();
        foreach ($options as &$option) {
            if ($option[0] === 'class') {
                $option[4] = DatabaseSeeder::class;
            }
        }

        return $options;
    }

protected function getOptions ( ) { $ options = parent :: getOptions ( ) ; foreach ( $ options as & $ option ) { if ( $ option [ 0 ] === 'class' ) { $ option [ 4 ] = DatabaseSeeder :: class ; } } return $ options ; }

Get the console command options.

@return array


public function render(RotateControl $rotateControl)
    {
        return $this->jsonBuilder
            ->reset()
            ->setValue('[position]', $this->controlPositionHelper->render($rotateControl->getControlPosition()), false)
            ->build();
    }

public function render ( RotateControl $ rotateControl ) { return $ this -> jsonBuilder -> reset ( ) -> setValue ( '[position]' , $ this -> controlPositionHelper -> render ( $ rotateControl -> getControlPosition ( ) ) , false ) -> build ( ) ; }

Renders a rotate control.

@param \Ivory\GoogleMap\Controls\RotateControl $rotateControl The rotate control.

@return string The JS output.


public function encode($value, bool $double_encode = false, int $flags = null)
    {
        if (is_array($value) || is_object($value)) {
            foreach ($value as $_key => &$_value) {
                $_value = $this->encode($_value, $double_encode, $flags);
            } // unset($_key, $_value); // Housekeeping.
            return $value;
        }
        if (!($string = (string) $value)) {
            return $string; // Nothing to do.
        }
        if (!isset($flags)) {
            $flags = ENT_HTML5 | ENT_QUOTES | ENT_SUBSTITUTE;
        }
        return htmlspecialchars($string, $flags, 'UTF-8', $double_encode);
    }

Escape HTML markup deeply.

@since 150424 Initial release.

@param mixed    $value         Any input value.
@param bool     $double_encode Encode existing entities? Defaults to `FALSE`.
@param int|null $flags         Optional. Defaults to `ENT_HTML5 | ENT_QUOTES | ENT_SUBSTITUTE`.

@return string|array|object Value after having been escaped deeply.


public function decode($value, int $flags = null)
    {
        if (is_array($value) || is_object($value)) {
            foreach ($value as $_key => &$_value) {
                $_value = $this->decode($_value, $flags);
            } // unset($_key, $_value);
            return $value;
        }
        if (!($string = (string) $value)) {
            return $string; // Nothing to do.
        }
        if (!isset($flags)) {
            $flags = ENT_HTML5 | ENT_QUOTES;
        }
        return html_entity_decode($string, $flags, 'UTF-8');
    }

public
function
decode
(
$
value
,
int
$
flags
=
)
{
if
(
is_array
(
$
value
)
||
is_object
(
$
value
)
)
{
foreach
(
$
value
as
$
_key
=>
&
$
_value
)
{
$
_value
=
$
this
->
decode
(
$
_value
,
$
flags
)
;
}
// unset($_key, $_value);
return
$
value
;
}
if
(
!
(
$
string
=
(
string
)
$
value
)
)
{
return
$
string
;
// Nothing to do.
}
if
(
!
isset
(
$
flags
)
)
{
$
flags
=
ENT_HTML5
|
ENT_QUOTES
;
}
return
html_entity_decode
(
$
string
,
$
flags
,
'UTF-8'
)
;
}

Unescape HTML markup deeply.

@since 150424 Initial release.

@param mixed $value Any input value.
@param int   $flags Optional. Defaults to `ENT_HTML5 | ENT_QUOTES`.

@return string|array|object Value after having been unescaped deeply.


public function callAction($method, $parameters)
    {
        if (method_exists($this, 'before')) {
            $this->app->call([$this, 'before'], ['method' => $method]);
        }

        $response = parent::callAction($method, $parameters);

        if ($this->cache > 0) {
            $response = Route::prepareResponse(App::make('request'), $response);
            $response->headers->addCacheControlDirective('public');
            $response->headers->addCacheControlDirective('max-age', (int)$this->cache);
        }

        return $response;
    }

public function callAction ( $ method , $ parameters ) { if ( method_exists ( $ this , 'before' ) ) { $ this -> app -> call ( [ $ this , 'before' ] , [ 'method' => $ method ] ) ; } $ response = parent :: callAction ( $ method , $ parameters ) ; if ( $ this -> cache > 0 ) { $ response = Route :: prepareResponse ( App :: make ( 'request' ) , $ response ) ; $ response -> headers -> addCacheControlDirective ( 'public' ) ; $ response -> headers -> addCacheControlDirective ( 'max-age' , ( int ) $ this -> cache ) ; } return $ response ; }

Execute an action on the controller.

@param  string $method
@param  array  $parameters

@return \Symfony\Component\HttpFoundation\Response


public function render(KMLLayer $kmlLayer, Map $map)
    {
        $this->jsonBuilder
            ->reset()
            ->setValue('[map]', $map->getJavascriptVariable(), false)
            ->setValues($kmlLayer->getOptions());

        return sprintf(
            '%s = new google.maps.KmlLayer("%s", %s);'.PHP_EOL,
            $kmlLayer->getJavascriptVariable(),
            $kmlLayer->getUrl(),
            $this->jsonBuilder->build()
        );
    }

Renders a kml layer.

@param \Ivory\GoogleMap\Layers\KMLLayer $kmlLayer The KML layer.
@param \Ivory\GoogleMap\Map             $map      The map.

@return string The JS output.


public function get(string $primary_key, $sub_key)
    {
        if (!$this->enabled) {
            return; // Not possible.
            //
        } elseif (!($key = $this->key($primary_key, $sub_key))) {
            return; // Fail; e.g., race condition.
        }
        $value = $this->Pool->get($key); // Possibly `false`.
        // See: <http://php.net/manual/en/memcached.get.php#92275>

        if ($this->Pool->getResultCode() === \Memcached::RES_SUCCESS) {
            return $value; // Return the value.
        }
    }

Get cache value by key.

@since 151216 Memcache utils.

@param string     $primary_key Primary key.
@param string|int $sub_key     Sub-key to get.

@return mixed|null Null if missing, or on failure.


public function set(string $primary_key, $sub_key, $value, int $expires_in = 0): bool
    {
        if (!$this->enabled) {
            return false; // Not possible.
        }
        $expires_in = max(0, $expires_in);
        $expires    = $expires_in ? time() + $expires_in : 0;

        if (!($key = $this->key($primary_key, $sub_key))) {
            return false; // Fail; e.g., race condition.
            //
        } elseif ($value === null || is_resource($value)) {
            throw $this->c::issue('Incompatible data type.');
        }
        do { // Avoid race issues.
            $cas      = $cas ?? 0;
            $attempts = $attempts ?? 0;
            ++$attempts; // Counter.

            $this->Pool->get($key, null, $cas);

            if ($this->Pool->getResultCode() === \Memcached::RES_NOTFOUND) {
                if ($this->Pool->add($key, $value, $expires)) {
                    return true; // All good; stop here.
                }
            } elseif ($this->Pool->cas($cas, $key, $value, $expires)) {
                return true; // All good; stop here.
            }
            $result_code = $this->Pool->getResultCode();
            //
        } while ($attempts < $this::MAX_WRITE_ATTEMPTS // Give up after X attempts.
                && ($result_code === \Memcached::RES_NOTSTORED || $result_code === \Memcached::RES_DATA_EXISTS));

        return false; // Fail; e.g., race condition or unexpected error.
    }

Set|update cache key.

@since 151216 Memcache utils.

@param string     $primary_key Primary key.
@param string|int $sub_key     Sub-key to set.
@param string     $value       Value to cache (1MB max).
@param int        $expires_in  Expires (in seconds).

@return bool True on success.


public function clear(string $primary_key, $sub_key = null, int $delay = 0): bool
    {
        if (!$this->enabled) {
            return false; // Not possible.
        }
        if (!isset($sub_key)) {
            $key = $this->nspKey($primary_key);
        } else {
            $key = $this->key($primary_key, $sub_key);
        }
        return $key && $this->Pool->delete($key, $delay);
    }

public
function
clear
(
string
$
primary_key
,
$
sub_key
=
,
int
$
delay
=
0
)
:
bool
{
if
(
!
$
this
->
enabled
)
{
return
false
;
// Not possible.
}
if
(
!
isset
(
$
sub_key
)
)
{
$
key
=
$
this
->
nspKey
(
$
primary_key
)
;
}
else
{
$
key
=
$
this
->
key
(
$
primary_key
,
$
sub_key
)
;
}
return
$
key
&&
$
this
->
Pool
->
delete
(
$
key
,
$
delay
)
;
}

Clear the cache.

@since 151216 Memcache utils.

@param string          $primary_key Primary key.
@param string|int|null $sub_key     Sub-key (optional).
@param int             $delay       Delay (in seconds).

@return bool True on success.


protected function key(string $primary_key, $sub_key): string
    {
        if (!$this->enabled) {
            return ''; // Not possible.
            //
        } elseif (!($namespaced_primary_key = $this->nspKey($primary_key))) {
            return ''; // Not possible; e.g., empty key.
        }
        $namespaced_primary_key_uuid = ''; // Initialize.

        do { // Avoid race issues.
            $attempts = $attempts ?? 0;
            ++$attempts; // Counter.

            if (($existing_namespaced_primary_key_uuid = (string) $this->Pool->get($namespaced_primary_key))) {
                $namespaced_primary_key_uuid = $existing_namespaced_primary_key_uuid;
                break; // All good; stop here.
            }
            if (!isset($new_namespaced_primary_key_uuid)) {
                $new_namespaced_primary_key_uuid = $this->c::uuidV4();
            }
            if ($this->Pool->add($namespaced_primary_key, $new_namespaced_primary_key_uuid)) {
                $namespaced_primary_key_uuid = $new_namespaced_primary_key_uuid;
                break; // All good; stop here.
            }
            $result_code = $this->Pool->getResultCode();
            //
        } while ($attempts < $this::MAX_WRITE_ATTEMPTS && $result_code === \Memcached::RES_NOTSTORED);

        if (!$namespaced_primary_key_uuid) {
            return ''; // Failure; e.g., race condition.
        }
        $sub_key                            = (string) $sub_key;
        $namespaced_primary_key_uuid_prefix = $namespaced_primary_key_uuid.'\\';
        $namespaced_key                     = $namespaced_primary_key_uuid_prefix.$sub_key;

        if (isset($namespaced_key[251])) {
            throw $this->c::issue(sprintf('Sub key too long; %1$s bytes max.', 250 - strlen($namespaced_primary_key_uuid_prefix)));
        }
        return $namespaced_key;
    }

protected
function
key
(
string
$
primary_key
,
$
sub_key
)
:
string
{
if
(
!
$
this
->
enabled
)
{
return
''
;
// Not possible.
//
}
elseif
(
!
(
$
namespaced_primary_key
=
$
this
->
nspKey
(
$
primary_key
)
)
)
{
return
''
;
// Not possible; e.g., empty key.
}
$
namespaced_primary_key_uuid
=
''
;
// Initialize.
do
{
// Avoid race issues.
$
attempts
=
$
attempts
??
0
;
++
$
attempts
;
// Counter.
if
(
(
$
existing_namespaced_primary_key_uuid
=
(
string
)
$
this
->
Pool
->
get
(
$
namespaced_primary_key
)
)
)
{
$
namespaced_primary_key_uuid
=
$
existing_namespaced_primary_key_uuid
;
break
;
// All good; stop here.
}
if
(
!
isset
(
$
new_namespaced_primary_key_uuid
)
)
{
$
new_namespaced_primary_key_uuid
=
$
this
->
c
::
uuidV4
(
)
;
}
if
(
$
this
->
Pool
->
add
(
$
namespaced_primary_key
,
$
new_namespaced_primary_key_uuid
)
)
{
$
namespaced_primary_key_uuid
=
$
new_namespaced_primary_key_uuid
;
break
;
// All good; stop here.
}
$
result_code
=
$
this
->
Pool
->
getResultCode
(
)
;
//
}
while
(
$
attempts
<
$
this
::
MAX_WRITE_ATTEMPTS
&&
$
result_code
===
\
Memcached
::
RES_NOTSTORED
)
;
if
(
!
$
namespaced_primary_key_uuid
)
{
return
''
;
// Failure; e.g., race condition.
}
$
sub_key
=
(
string
)
$
sub_key
;
$
namespaced_primary_key_uuid_prefix
=
$
namespaced_primary_key_uuid
.
'\\'
;
$
namespaced_key
=
$
namespaced_primary_key_uuid_prefix
.
$
sub_key
;
if
(
isset
(
$
namespaced_key
[
251
]
)
)
{
throw
$
this
->
c
::
issue
(
sprintf
(
'Sub key too long; %1$s bytes max.'
,
250
strlen
(
$
namespaced_primary_key_uuid_prefix
)
)
)
;
}
return
$
namespaced_key
;
}

Namespace a key.

@since 151216 Memcache utils.

@param string     $primary_key Primary key.
@param string|int $sub_key     Sub-key.

@return string Full namespaced cache key.


protected function nspKey(string $primary_key): string
    {
        if (!$this->enabled) {
            return ''; // Not possible.
            //
        } elseif (!isset($primary_key[0])) {
            return ''; // Not possible.
        }
        $namespace_prefix       = 'x___'.$this->namespace.'\\';
        $namespaced_primary_key = $namespace_prefix.$primary_key;

        if (isset($namespaced_primary_key[251])) {
            throw $this->c::issue(sprintf('Primary key too long; %1$s bytes max.', 250 - strlen($namespace_prefix)));
        }
        return $namespaced_primary_key;
    }

protected
function
nspKey
(
string
$
primary_key
)
:
string
{
if
(
!
$
this
->
enabled
)
{
return
''
;
// Not possible.
//
}
elseif
(
!
isset
(
$
primary_key
[
0
]
)
)
{
return
''
;
// Not possible.
}
$
namespace_prefix
=
'x___'
.
$
this
->
namespace
.
'\\'
;
$
namespaced_primary_key
=
$
namespace_prefix
.
$
primary_key
;
if
(
isset
(
$
namespaced_primary_key
[
251
]
)
)
{
throw
$
this
->
c
::
issue
(
sprintf
(
'Primary key too long; %1$s bytes max.'
,
250
strlen
(
$
namespace_prefix
)
)
)
;
}
return
$
namespaced_primary_key
;
}

Namespace primary key.

@since 151216 Memcache utils.

@param string $primary_key Primary key.

@return string Namespaced primary key.


protected function serversDiffer(): bool
    {
        if (!$this->enabled) {
            return false; // Not possible.
        }
        $active_servers = []; // Initialize.

        foreach ($this->Pool->getServerList() as $_server) {
            $active_servers[$_server['host'].':'.$_server['port']] = $_server;
        } // unset($_server); // Housekeeping.

        if (count($this->servers) !== count($active_servers)) {
            return true; // They definitely differ.
        }
        foreach ($this->servers as $_key => $_server) {
            if (!isset($active_servers[$_key])) {
                return true;
            } // unset($_key, $_server);
        }
        foreach ($active_servers as $_key => $_server) {
            if (!isset($this->servers[$_key])) {
                return true;
            } // unset($_key, $_server);
        }
        return false;
    }

protected
function
serversDiffer
(
)
:
bool
{
if
(
!
$
this
->
enabled
)
{
return
false
;
// Not possible.
}
$
active_servers
=
[
]
;
// Initialize.
foreach
(
$
this
->
Pool
->
getServerList
(
)
as
$
_server
)
{
$
active_servers
[
$
_server
[
'host'
]
.
':'
.
$
_server
[
'port'
]
]
=
$
_server
;
}
// unset($_server); // Housekeeping.
if
(
count
(
$
this
->
servers
)
!==
count
(
$
active_servers
)
)
{
return
true
;
// They definitely differ.
}
foreach
(
$
this
->
servers
as
$
_key
=>
$
_server
)
{
if
(
!
isset
(
$
active_servers
[
$
_key
]
)
)
{
return
true
;
}
// unset($_key, $_server);
}
foreach
(
$
active_servers
as
$
_key
=>
$
_server
)
{
if
(
!
isset
(
$
this
->
servers
[
$
_key
]
)
)
{
return
true
;
}
// unset($_key, $_server);
}
return
false
;
}

Servers differ? i.e., current vs. active.

@since 151216 Memcache utils.

@return bool True if servers differ.

Servers differ? i . e . current vs . active .


protected function maybeAddServerConnections()
    {
        if (!$this->enabled) {
            return; // Not possible.
        }
        if ($this->serversDiffer()) {
            $this->Pool->quit();
            $this->Pool->resetServerList();

            $this->Pool->setOption(\Memcached::OPT_NO_BLOCK, true);
            $this->Pool->setOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE, true);

            if (\Memcached::HAVE_IGBINARY) { // Size and speed gains.
                $this->Pool->setOption(\Memcached::OPT_BINARY_PROTOCOL, true);
                $this->Pool->setOption(\Memcached::OPT_SERIALIZER, \Memcached::SERIALIZER_IGBINARY);
            }
            $this->Pool->setOption(\Memcached::OPT_CONNECT_TIMEOUT, 1000);
            $this->Pool->setOption(\Memcached::OPT_POLL_TIMEOUT, 1000);
            $this->Pool->setOption(\Memcached::OPT_RETRY_TIMEOUT, 1);

            $this->Pool->setOption(\Memcached::OPT_SEND_TIMEOUT, 1000000);
            $this->Pool->setOption(\Memcached::OPT_RECV_TIMEOUT, 1000000);

            $this->Pool->addServers($this->servers);
        }
    }

protected
function
maybeAddServerConnections
(
)
{
if
(
!
$
this
->
enabled
)
{
return
;
// Not possible.
}
if
(
$
this
->
serversDiffer
(
)
)
{
$
this
->
Pool
->
quit
(
)
;
$
this
->
Pool
->
resetServerList
(
)
;
$
this
->
Pool
->
setOption
(
\
Memcached
::
OPT_NO_BLOCK
,
true
)
;
$
this
->
Pool
->
setOption
(
\
Memcached
::
OPT_LIBKETAMA_COMPATIBLE
,
true
)
;
if
(
\
Memcached
::
HAVE_IGBINARY
)
{
// Size and speed gains.
$
this
->
Pool
->
setOption
(
\
Memcached
::
OPT_BINARY_PROTOCOL
,
true
)
;
$
this
->
Pool
->
setOption
(
\
Memcached
::
OPT_SERIALIZER
,
\
Memcached
::
SERIALIZER_IGBINARY
)
;
}
$
this
->
Pool
->
setOption
(
\
Memcached
::
OPT_CONNECT_TIMEOUT
,
1000
)
;
$
this
->
Pool
->
setOption
(
\
Memcached
::
OPT_POLL_TIMEOUT
,
1000
)
;
$
this
->
Pool
->
setOption
(
\
Memcached
::
OPT_RETRY_TIMEOUT
,
1
)
;
$
this
->
Pool
->
setOption
(
\
Memcached
::
OPT_SEND_TIMEOUT
,
1000000
)
;
$
this
->
Pool
->
setOption
(
\
Memcached
::
OPT_RECV_TIMEOUT
,
1000000
)
;
$
this
->
Pool
->
addServers
(
$
this
->
servers
)
;
}
}

Maybe add server connections.

@since 151216 Memcache utils.


public function renderHtmlContainer(Autocomplete $autocomplete)
    {
        $inputAttributes = $autocomplete->getInputAttributes();

        $inputAttributes['id'] = $autocomplete->getInputId();

        if ($autocomplete->hasValue()) {
            $inputAttributes['value'] = $autocomplete->getValue();
        }

        $htmlAttributes = array();
        foreach ($inputAttributes as $attribute => $value) {
            $htmlAttributes[] = sprintf('%s="%s"', $attribute, $value);
        }

        return sprintf('<input %s />'.PHP_EOL, implode(' ', $htmlAttributes));
    }

public
function
renderHtmlContainer
(
Autocomplete
$
autocomplete
)
{
$
inputAttributes
=
$
autocomplete
->
getInputAttributes
(
)
;
$
inputAttributes
[
'id'
]
=
$
autocomplete
->
getInputId
(
)
;
if
(
$
autocomplete
->
hasValue
(
)
)
{
$
inputAttributes
[
'value'
]
=
$
autocomplete
->
getValue
(
)
;
}
$
htmlAttributes
=
array
(
)
;
foreach
(
$
inputAttributes
as
$
attribute
=>
$
value
)
{
$
htmlAttributes
[
]
=
sprintf
(
'%s="%s"'
,
$
attribute
,
$
value
)
;
}
return
sprintf
(
'<input %s />'
.
PHP_EOL
,
implode
(
' '
,
$
htmlAttributes
)
)
;
}

Renders the autocomplete HTML container.

@param \Ivory\GoogleMap\Places\Autocomplete $autocomplete The autocomplete.

@return string The HTML output.

Renders the autocomplete HTML container .


public function renderJavascripts(Autocomplete $autocomplete)
    {
        $output = array();

        if (!$this->apiHelper->isLoaded() && !$autocomplete->isAsync()) {
            $output[] = $this->apiHelper->render($autocomplete->getLanguage(), array('places'));
        }

        $output[] = '<script type="text/javascript">'.PHP_EOL;

        if ($autocomplete->isAsync()) {
            $output[] = 'function load_ivory_google_place () {'.PHP_EOL;
        }

        if ($autocomplete->hasBound()) {
            if (!$autocomplete->getBound()->hasCoordinates()) {
                throw HelperException::invalidAutocompleteBound();
            }

            $output[] = $this->coordinateHelper->render($autocomplete->getBound()->getSouthWest());
            $output[] = $this->coordinateHelper->render($autocomplete->getBound()->getNorthEast());
            $output[] = $this->boundHelper->render($autocomplete->getBound());
        }

        $output[] = $this->renderAutocomplete($autocomplete);

        if ($autocomplete->isAsync()) {
            $output[] = '}'.PHP_EOL;
        }

        $output[] = '</script>'.PHP_EOL;

        if (!$this->apiHelper->isLoaded() && $autocomplete->isAsync()) {
            $output[] = $this->apiHelper->render(
                $autocomplete->getLanguage(),
                array('places'),
                'load_ivory_google_place'
            );
        }

        return implode('', $output);
    }

public
function
renderJavascripts
(
Autocomplete
$
autocomplete
)
{
$
output
=
array
(
)
;
if
(
!
$
this
->
apiHelper
->
isLoaded
(
)
&&
!
$
autocomplete
->
isAsync
(
)
)
{
$
output
[
]
=
$
this
->
apiHelper
->
render
(
$
autocomplete
->
getLanguage
(
)
,
array
(
'places'
)
)
;
}
$
output
[
]
=
'<script type="text/javascript">'
.
PHP_EOL
;
if
(
$
autocomplete
->
isAsync
(
)
)
{
$
output
[
]
=
'function load_ivory_google_place () {'
.
PHP_EOL
;
}
if
(
$
autocomplete
->
hasBound
(
)
)
{
if
(
!
$
autocomplete
->
getBound
(
)
->
hasCoordinates
(
)
)
{
throw
HelperException
::
invalidAutocompleteBound
(
)
;
}
$
output
[
]
=
$
this
->
coordinateHelper
->
render
(
$
autocomplete
->
getBound
(
)
->
getSouthWest
(
)
)
;
$
output
[
]
=
$
this
->
coordinateHelper
->
render
(
$
autocomplete
->
getBound
(
)
->
getNorthEast
(
)
)
;
$
output
[
]
=
$
this
->
boundHelper
->
render
(
$
autocomplete
->
getBound
(
)
)
;
}
$
output
[
]
=
$
this
->
renderAutocomplete
(
$
autocomplete
)
;
if
(
$
autocomplete
->
isAsync
(
)
)
{
$
output
[
]
=
'}'
.
PHP_EOL
;
}
$
output
[
]
=
'</script>'
.
PHP_EOL
;
if
(
!
$
this
->
apiHelper
->
isLoaded
(
)
&&
$
autocomplete
->
isAsync
(
)
)
{
$
output
[
]
=
$
this
->
apiHelper
->
render
(
$
autocomplete
->
getLanguage
(
)
,
array
(
'places'
)
,
'load_ivory_google_place'
)
;
}
return
implode
(
''
,
$
output
)
;
}

Renders the autocomplete javascripts.

@param \Ivory\GoogleMap\Places\Autocomplete $autocomplete The autocomplete.

@throws \Ivory\GoogleMap\Exception\HelperException if the autocomplete bound does not have coordinates.

@return string The HTML output.


public function renderAutocomplete(Autocomplete $autocomplete)
    {
        $this->jsonBuilder->reset();

        if ($autocomplete->hasTypes()) {
            $this->jsonBuilder->setValue('[types]', $autocomplete->getTypes());
        }

        if ($autocomplete->hasBound()) {
            $this->jsonBuilder->setValue('[bounds]', $autocomplete->getBound()->getJavascriptVariable(), false);
        }

        if ($autocomplete->hasComponentRestrictions()) {
            $this->jsonBuilder->setValue('[componentRestrictions]', $autocomplete->getComponentRestrictions());
        }

        if (!$this->jsonBuilder->hasValues()) {
            $this->jsonBuilder->setJsonEncodeOptions(JSON_FORCE_OBJECT);
        }

        return sprintf(
            '%s = new google.maps.places.Autocomplete(document.getElementById(\'%s\'), %s);'.PHP_EOL,
            $autocomplete->getJavascriptVariable(),
            $autocomplete->getInputId(),
            $this->jsonBuilder->build()
        );
    }

Renders the autocomplete.

@param \Ivory\GoogleMap\Places\Autocomplete $autocomplete The autocomplete.

@return string The JS output.


public function register()
    {
        $this->app->singleton(DatabaseSeeder::class);
        $this->app->extend('command.seed', function () {
            return new SeedCommand($this->app['db']);
        });
    }

public function register ( ) { $ this -> app -> singleton ( DatabaseSeeder :: class ) ; $ this -> app -> extend ( 'command.seed' , function ( ) { return new SeedCommand ( $ this -> app [ 'db' ] ) ; } ) ; }


public function closeRequestEarly()
    {
        ignore_user_abort(true);
        $this->sessionWriteClose();

        if ($this->c::canCallFunc('fastcgi_finish_request')) {
            fastcgi_finish_request();
        } else {
            $this->buffersEndFlush();
            header('connection: close');
        }
    }

public
function
closeRequestEarly
(
)
{
ignore_user_abort
(
true
)
;
$
this
->
sessionWriteClose
(
)
;
if
(
$
this
->
c
::
canCallFunc
(
'fastcgi_finish_request'
)
)
{
fastcgi_finish_request
(
)
;
}
else
{
$
this
->
buffersEndFlush
(
)
;
header
(
'connection: close'
)
;
}
}

Closes a request early.

@since 170824.30708 Early close of request.


public function gzipOff()
    {
        if (headers_sent()) {
            throw $this->c::issue('Headers already sent!');
        }
        @ini_set('zlib.output_compression', 'off');

        if ($this->c::canCallFunc('apache_setenv')) {
            @apache_setenv('no-gzip', '1');
        }
    }

public
function
gzipOff
(
)
{
if
(
headers_sent
(
)
)
{
throw
$
this
->
c
::
issue
(
'Headers already sent!'
)
;
}
@
ini_set
(
'zlib.output_compression'
,
'off'
)
;
if
(
$
this
->
c
::
canCallFunc
(
'apache_setenv'
)
)
{
@
apache_setenv
(
'no-gzip'
,
'1'
)
;
}
}

Disables GZIP compression.

@since 150424 Initial release.


public function setLocation()
    {
        $args = func_get_args();

        if (isset($args[0]) && is_string($args[0])) {
            $this->location = $args[0];
        } elseif (isset($args[0]) && ($args[0] instanceof Coordinate)) {
            $this->location = $args[0];
        } elseif ((isset($args[0]) && is_numeric($args[0])) && (isset($args[1]) && is_numeric($args[1]))) {
            if ($this->location === null) {
                $this->location = new Coordinate();
            }

            $this->location->setLatitude($args[0]);
            $this->location->setLongitude($args[1]);

            if (isset($args[2]) && is_bool($args[2])) {
                $this->location->setNoWrap($args[2]);
            }
        } else {
            throw DirectionsException::invalidDirectionsWaypointLocation();
        }
    }

public function setLocation ( ) { $ args = func_get_args ( ) ; if ( isset ( $ args [ 0 ] ) && is_string ( $ args [ 0 ] ) ) { $ this -> location = $ args [ 0 ] ; } elseif ( isset ( $ args [ 0 ] ) && ( $ args [ 0 ] instanceof Coordinate ) ) { $ this -> location = $ args [ 0 ] ; } elseif ( ( isset ( $ args [ 0 ] ) && is_numeric ( $ args [ 0 ] ) ) && ( isset ( $ args [ 1 ] ) && is_numeric ( $ args [ 1 ] ) ) ) { if ( $ this -> location === null ) { $ this -> location = new Coordinate ( ) ; } $ this -> location -> setLatitude ( $ args [ 0 ] ) ; $ this -> location -> setLongitude ( $ args [ 1 ] ) ; if ( isset ( $ args [ 2 ] ) && is_bool ( $ args [ 2 ] ) ) { $ this -> location -> setNoWrap ( $ args [ 2 ] ) ; } } else { throw DirectionsException :: invalidDirectionsWaypointLocation ( ) ; } }

Sets the directions waypoint location.

Available prototypes:
- function setLocation(string $destination)
- function setLocation(Ivory\GoogleMap\Base\Coordinate $destination)
- function setLocation(double $latitude, double $longitude, boolean $noWrap)

@throws \Ivory\GoogleMap\Exception\DirectionsException If the location is not valid (prototypes).


public function setStopover($stopover = null)
    {
        if (!is_bool($stopover) && ($stopover !== null)) {
            throw DirectionsException::invalidDirectionsWaypointStopover();
        }

        $this->stopover = $stopover;
    }

public function setStopover ( $ stopover = null ) { if ( ! is_bool ( $ stopover ) && ( $ stopover !== null ) ) { throw DirectionsException :: invalidDirectionsWaypointStopover ( ) ; } $ this -> stopover = $ stopover ; }

Sets the directions waypoint stopover flag.

@param boolean $stopover The directions waypoint stopover flag.

Sets the directions waypoint stopover flag .


public function errorReason(int $code): string
    {
        switch ($code) {
            case UPLOAD_ERR_INI_SIZE:
                return __('Exceeds `upload_max_filesize` directive in `php.ini`.');

            case UPLOAD_ERR_FORM_SIZE:
                return __('Exceeds `MAX_FILE_SIZE` directive in the HTML form.');

            case UPLOAD_ERR_PARTIAL:
                return __('Data missing; partial.');

            case UPLOAD_ERR_NO_FILE:
                return __('Missing file.');

            case UPLOAD_ERR_NO_TMP_DIR:
                return __('Missing temp dir.');

            case UPLOAD_ERR_CANT_WRITE:
                return __('Failed to write file to disk.');

            case UPLOAD_ERR_EXTENSION:
                return __('A PHP extension stopped the file upload.');

            default: // Unknown error code.
                return __('Unknown error.');
        }
    }

Error reason.

@since 160926 Upload utils.

@param int $code An upload error code.

@return string An upload error reason.


public function set(string $file, string $ext): string
    {
        if (!$file || !$ext) {
            return $file; // Not possible.
        }
        return $file = preg_replace('/\.[^.]+$/ui', '', $file).'.'.$ext;
    }

public
function
set
(
string
$
file
,
string
$
ext
)
:
string
{
if
(
!
$
file
||
!
$
ext
)
{
return
$
file
;
// Not possible.
}
return
$
file
=
preg_replace
(
'/\.[^.]+$/ui'
,
''
,
$
file
)
.
'.'
.
$
ext
;
}

Set file extension.

@since 17xxxx Extension utils.

@param string $file Image file.
@param string $ext  New extension.

@return string File w/ extension.


public function change(string $file, string $ext): string
    {
        if (!$file || !$ext) {
            return $file; // Not possible.
        }
        return $file = preg_replace('/\.[^.]+$/ui', '.'.$ext, $file);
    }

public
function
change
(
string
$
file
,
string
$
ext
)
:
string
{
if
(
!
$
file
||
!
$
ext
)
{
return
$
file
;
// Not possible.
}
return
$
file
=
preg_replace
(
'/\.[^.]+$/ui'
,
'.'
.
$
ext
,
$
file
)
;
}

Change file extension.

@since 17xxxx Extension utils.

@param string $file Image file.
@param string $ext  New extension.

@return string File w/ possible extension.


public function hasOption($option)
    {
        if (!is_string($option)) {
            throw AssetException::invalidOption();
        }

        return isset($this->options[$option]);
    }

public function hasOption ( $ option ) { if ( ! is_string ( $ option ) ) { throw AssetException :: invalidOption ( ) ; } return isset ( $ this -> options [ $ option ] ) ; }

Checks if the option exists.

@param string $option The option.

@throws \Ivory\GoogleMap\Exception\AssetException If the option is not valid.

@return boolean TRUE if the option exists else FALSE.


public function getOption($option)
    {
        if (!$this->hasOption($option)) {
            throw AssetException::optionDoesNotExist($option);
        }

        return $this->options[$option];
    }

public function getOption ( $ option ) { if ( ! $ this -> hasOption ( $ option ) ) { throw AssetException :: optionDoesNotExist ( $ option ) ; } return $ this -> options [ $ option ] ; }

Gets a specific option.

@param string $option The option.

@throws \Ivory\GoogleMap\Exception\AssetException If the option does not exist.

@return mixed The option value.


public function setOption($option, $value)
    {
        if (!is_string($option)) {
            throw AssetException::invalidOption();
        }

        $this->options[$option] = $value;
    }

public function setOption ( $ option , $ value ) { if ( ! is_string ( $ option ) ) { throw AssetException :: invalidOption ( ) ; } $ this -> options [ $ option ] = $ value ; }

Sets a specific option.

@param string $option The option
@param mixed  $value  The option value.

@throws \Ivory\GoogleMap\Exception\AssetException If the option is not valid.


public function removeOption($option)
    {
        if (!$this->hasOption($option)) {
            throw AssetException::optionDoesNotExist($option);
        }

        unset($this->options[$option]);
    }

public function removeOption ( $ option ) { if ( ! $ this -> hasOption ( $ option ) ) { throw AssetException :: optionDoesNotExist ( $ option ) ; } unset ( $ this -> options [ $ option ] ) ; }

Removes an option.

@param string $option The option.

@throws \Ivory\GoogleMap\Exception\AssetException If the option does not exist.


private function modifyRequestAttributes(RouteMatchInterface $routeMatch, ServerRequestInterface $request): ServerRequestInterface
    {
        if ($routeMatch->isMethodFailure() === true) {
            return $request
                ->withAttribute('actionName', self::METHOD_NOT_ALLOWED_ACTION)
                ->withAttribute('allowedMethods', $routeMatch->getAllowedMethods());
        }

        if ($routeMatch->isFailure() === true) {
            return $request->withAttribute('actionName', self::ROUTE_NOT_FOUND_ACTION);
        }

        return $request
            ->withAttribute('actionName', $routeMatch->getAction())
            ->withAttribute('parameters', $routeMatch->getParameters());
    }

private function modifyRequestAttributes ( RouteMatchInterface $ routeMatch , ServerRequestInterface $ request ) : ServerRequestInterface { if ( $ routeMatch -> isMethodFailure ( ) === true ) { return $ request -> withAttribute ( 'actionName' , self :: METHOD_NOT_ALLOWED_ACTION ) -> withAttribute ( 'allowedMethods' , $ routeMatch -> getAllowedMethods ( ) ) ; } if ( $ routeMatch -> isFailure ( ) === true ) { return $ request -> withAttribute ( 'actionName' , self :: ROUTE_NOT_FOUND_ACTION ) ; } return $ request -> withAttribute ( 'actionName' , $ routeMatch -> getAction ( ) ) -> withAttribute ( 'parameters' , $ routeMatch -> getParameters ( ) ) ; }

Modify the request and add information from the matched route to it.

@param RouteMatchInterface $routeMatch
@param ServerRequestInterface $request

@return ServerRequestInterface

Modify the request and add information from the matched route to it .


public function setZoomControlStyle($zoomControlStyle)
    {
        if (!in_array($zoomControlStyle, ZoomControlStyle::getZoomControlStyles())) {
            throw ControlException::invalidZoomControlStyle();
        }

        $this->zoomControlStyle = $zoomControlStyle;
    }

public function setZoomControlStyle ( $ zoomControlStyle ) { if ( ! in_array ( $ zoomControlStyle , ZoomControlStyle :: getZoomControlStyles ( ) ) ) { throw ControlException :: invalidZoomControlStyle ( ) ; } $ this -> zoomControlStyle = $ zoomControlStyle ; }

Sets the zoom control style.

@param string $zoomControlStyle The zoom control style.

@throws \Ivory\GoogleMap\Exception\ControlException If the zoom control style is not valid.


public function decodeOne(string $hash_id): int
    {
        $ids       = $this->Parser->decode($hash_id);
        return $id = (int) ($ids[0] ?? 0);
    }

public function decodeOne ( string $ hash_id ) : int { $ ids = $ this -> Parser -> decode ( $ hash_id ) ; return $ id = ( int ) ( $ ids [ 0 ] ?? 0 ) ; }

Decodes a hash ID.

@since 161003 Single hash ID.

@param string $hash_id Hash ID.

@return int One decoded ID.


public function setResults(array $results)
    {
        $this->results = array();

        foreach ($results as $result) {
            $this->addResult($result);
        }
    }

public function setResults ( array $ results ) { $ this -> results = array ( ) ; foreach ( $ results as $ result ) { $ this -> addResult ( $ result ) ; } }

Sets the geocoder results

@param array $results The geocoder results.


public function setStatus($status)
    {
        if (!in_array($status, GeocoderStatus::getGeocoderStatus())) {
            throw GeocodingException::invalidGeocoderResponseStatus();
        }

        $this->status = $status;
    }

public function setStatus ( $ status ) { if ( ! in_array ( $ status , GeocoderStatus :: getGeocoderStatus ( ) ) ) { throw GeocodingException :: invalidGeocoderResponseStatus ( ) ; } $ this -> status = $ status ; }

Sets the geocoder results status.

@param string $status The geocoder result status.

@throws \Ivory\GoogleMap\Exception\GeocodingException If the status is not valid.


public function isValid(string $string): bool
    {
        if (!isset($string[0])) {
            return true; // Nothing to do.
        }
        return (bool) preg_match('/^./us', $string);
    }

public
function
isValid
(
string
$
string
)
:
bool
{
if
(
!
isset
(
$
string
[
0
]
)
)
{
return
true
;
// Nothing to do.
}
return
(
bool
)
preg_match
(
'/^./us'
,
$
string
)
;
}

Is valid UTF-8?

@since 150424 Enhancing multibyte support.

@param string $string Input string to test.

@return bool True if is valid UTF-8.


public function isEngine(): bool
    {
        if (($is = &$this->cacheKey(__FUNCTION__)) !== null) {
            return $is; // Cached this already.
        }
        $user_agent = $_SERVER['HTTP_USER_AGENT'] ?? '';
        return $is  = $user_agent && preg_match('/(?:blink|gecko|konqueror|msie|opera|playstation|presto|trident|webkit)/ui', $user_agent);
    }

Is a browser engine.

@since 170413.34876 User-Agent utils.

@return bool True if is engine.

@see https://jas.xyz/2p3VIbG


public function normalize($value, bool $allow_trailing_slash = false)
    {
        if (is_array($value) || is_object($value)) {
            foreach ($value as $_key => &$_value) {
                $_value = $this->normalize($_value);
            } // unset($_key, $_value);
            return $value;
        }
        if (!($string = (string) $value)) {
            return $string; // Nothing to do.
        }
        $stream_wrapper_regex = '/^(?<stream_wrapper>'.$this::FS_REGEX_FRAG_STREAM_WRAPPER.')/uS';
        $drive_prefix_regex   = '/^(?<drive_letter>'.$this::FS_REGEX_FRAG_DRIVE_PREFIX.')/uS';

        if (mb_strpos($string, '://') !== false && preg_match($stream_wrapper_regex, $string, $stream_wrapper)) {
            $string = preg_replace($stream_wrapper_regex, '', $string);
        }
        if (mb_strpos($string, ':') !== false && preg_match($drive_prefix_regex, $stringm, $drive_prefix)) {
            $string = preg_replace($stream_wrapper_regex, '', $string);
        }
        $string = str_replace([DIRECTORY_SEPARATOR, '\\', '/'], '/', $string);
        $string = preg_replace('/\/+/u', '/', $string); // Remove extra slashes.
        $string = $allow_trailing_slash ? $string : $this->c::mbRTrim($string, '/');

        if (!empty($drive_prefix[0])) {
            $string = mb_strtoupper($drive_prefix[0]).$string;
        }
        if (!empty($stream_wrapper[0])) {
            $string = mb_strtolower($stream_wrapper[0]).$string;
        }
        return $string;
    }

public
function
normalize
(
$
value
,
bool
$
allow_trailing_slash
=
false
)
{
if
(
is_array
(
$
value
)
||
is_object
(
$
value
)
)
{
foreach
(
$
value
as
$
_key
=>
&
$
_value
)
{
$
_value
=
$
this
->
normalize
(
$
_value
)
;
}
// unset($_key, $_value);
return
$
value
;
}
if
(
!
(
$
string
=
(
string
)
$
value
)
)
{
return
$
string
;
// Nothing to do.
}
$
stream_wrapper_regex
=
'/^(?<stream_wrapper>'
.
$
this
::
FS_REGEX_FRAG_STREAM_WRAPPER
.
')/uS'
;
$
drive_prefix_regex
=
'/^(?<drive_letter>'
.
$
this
::
FS_REGEX_FRAG_DRIVE_PREFIX
.
')/uS'
;
if
(
mb_strpos
(
$
string
,
'://'
)
!==
false
&&
preg_match
(
$
stream_wrapper_regex
,
$
string
,
$
stream_wrapper
)
)
{
$
string
=
preg_replace
(
$
stream_wrapper_regex
,
''
,
$
string
)
;
}
if
(
mb_strpos
(
$
string
,
':'
)
!==
false
&&
preg_match
(
$
drive_prefix_regex
,
$
stringm
,
$
drive_prefix
)
)
{
$
string
=
preg_replace
(
$
stream_wrapper_regex
,
''
,
$
string
)
;
}
$
string
=
str_replace
(
[
DIRECTORY_SEPARATOR
,
'\\'
,
'/'
]
,
'/'
,
$
string
)
;
$
string
=
preg_replace
(
'/\/+/u'
,
'/'
,
$
string
)
;
// Remove extra slashes.
$
string
=
$
allow_trailing_slash
$
string
:
$
this
->
c
::
mbRTrim
(
$
string
,
'/'
)
;
if
(
!
empty
(
$
drive_prefix
[
0
]
)
)
{
$
string
=
mb_strtoupper
(
$
drive_prefix
[
0
]
)
.
$
string
;
}
if
(
!
empty
(
$
stream_wrapper
[
0
]
)
)
{
$
string
=
mb_strtolower
(
$
stream_wrapper
[
0
]
)
.
$
string
;
}
return
$
string
;
}

Normalizes directory separators deeply.

@since 150424 Initial release.

@param mixed $value                Any input value.
@param bool  $allow_trailing_slash Optional; defaults to a FALSE value.

@return string|array|object Normalized directory/file path.

Normalizes directory separators deeply .


protected function pageUrl(int $page): string
    {
        if ($this->page_url_callback && is_callable($this->page_url_callback)) {
            return str_replace($this->page_replacement_code, $page, (string) $this->page_url_callback($page));
        }
        return str_replace($this->page_replacement_code, $page, $this->page_url);
    }

protected function pageUrl ( int $ page ) : string { if ( $ this -> page_url_callback && is_callable ( $ this -> page_url_callback ) ) { return str_replace ( $ this -> page_replacement_code , $ page , ( string ) $ this -> page_url_callback ( $ page ) ) ; } return str_replace ( $ this -> page_replacement_code , $ page , $ this -> page_url ) ; }

Get page URL.

@since 170117 Paginator.

@param int $page Page number.

@return string Page URL.


public function setAvoidHighways($avoidHighways = null)
    {
        if (!is_bool($avoidHighways) && ($avoidHighways !== null)) {
            throw DistanceMatrixException::invalidDistanceMatrixRequestAvoidHighways();
        }

        $this->avoidHighways = $avoidHighways;
    }

Sets if the the distance matrix request avoids hightways.

@param boolean $avoidHighways TRUE if the distance matrix request avoids hightways else FALSE.

@throws \Ivory\GoogleMap\Exception\DistanceMatrixException If the avoid highways flag is not valid.

Sets if the the distance matrix request avoids hightways .


public function setAvoidTolls($avoidTolls = null)
    {
        if (!is_bool($avoidTolls) && ($avoidTolls !== null)) {
            throw DistanceMatrixException::invalidDistanceMatrixRequestAvoidTolls();
        }

        $this->avoidTolls = $avoidTolls;
    }

public function setAvoidTolls ( $ avoidTolls = null ) { if ( ! is_bool ( $ avoidTolls ) && ( $ avoidTolls !== null ) ) { throw DistanceMatrixException :: invalidDistanceMatrixRequestAvoidTolls ( ) ; } $ this -> avoidTolls = $ avoidTolls ; }

Sets if the the distance matrix request avoids tolls.

@param boolean $avoidTolls TRUE if the distance matrix request avoids tolls else FALSE.

@throws \Ivory\GoogleMap\Exception\DistanceMatrixException If the avoid tolls flag is not valid.

Sets if the the distance matrix request avoids tolls .


public function setDestinations(array $destinations = array())
    {
        $this->destinations = array();

        foreach ($destinations as $destination) {
            $this->addDestination($destination);
        }
    }

public function setDestinations ( array $ destinations = array ( ) ) { $ this -> destinations = array ( ) ; foreach ( $ destinations as $ destination ) { $ this -> addDestination ( $ destination ) ; } }

Sets the request destinations.

@param array $destinations The distance matrix request destinations.


public function addDestination()
    {
        $args = func_get_args();

        if (isset($args[0]) && is_string($args[0])) {
            $this->destinations[] = $args[0];
        } elseif (isset($args[0]) && ($args[0] instanceof Coordinate)) {
            $this->destinations[] = $args[0];
        } elseif ((isset($args[0]) && is_numeric($args[0])) && (isset($args[1]) && is_numeric($args[1]))) {
            $destination = new Coordinate();
            $destination->setLatitude($args[0]);
            $destination->setLongitude($args[1]);

            if (isset($args[2]) && is_bool($args[2])) {
                $destination->setNoWrap($args[2]);
            }

            $this->destinations[] = $destination;
        } else {
            throw DistanceMatrixException::invalidDistanceMatrixRequestDestination();
        }
    }

public function addDestination ( ) { $ args = func_get_args ( ) ; if ( isset ( $ args [ 0 ] ) && is_string ( $ args [ 0 ] ) ) { $ this -> destinations [ ] = $ args [ 0 ] ; } elseif ( isset ( $ args [ 0 ] ) && ( $ args [ 0 ] instanceof Coordinate ) ) { $ this -> destinations [ ] = $ args [ 0 ] ; } elseif ( ( isset ( $ args [ 0 ] ) && is_numeric ( $ args [ 0 ] ) ) && ( isset ( $ args [ 1 ] ) && is_numeric ( $ args [ 1 ] ) ) ) { $ destination = new Coordinate ( ) ; $ destination -> setLatitude ( $ args [ 0 ] ) ; $ destination -> setLongitude ( $ args [ 1 ] ) ; if ( isset ( $ args [ 2 ] ) && is_bool ( $ args [ 2 ] ) ) { $ destination -> setNoWrap ( $ args [ 2 ] ) ; } $ this -> destinations [ ] = $ destination ; } else { throw DistanceMatrixException :: invalidDistanceMatrixRequestDestination ( ) ; } }

Adds a destination to the request.

Available prototypes:
- function addDestination(string $destination)
- function addDestination(Ivory\GoogleMap\Base\Coordinate $destination)
- function addDestination(double $latitude, double $longitude, boolean $noWrap)

@throws \Ivory\GoogleMap\Exception\DistanceMatrixException If the destination is not valid (prototypes).


public function addOrigin()
    {
        $args = func_get_args();

        if (isset($args[0]) && is_string($args[0])) {
            $this->origins[] = $args[0];
        } elseif (isset($args[0]) && ($args[0] instanceof Coordinate)) {
            $this->origins[] = $args[0];
        } elseif ((isset($args[0]) && is_numeric($args[0])) && (isset($args[1]) && is_numeric($args[1]))) {
            $origin = new Coordinate();
            $origin->setLatitude($args[0]);
            $origin->setLongitude($args[1]);

            if (isset($args[2]) && is_bool($args[2])) {
                $origin->setNoWrap($args[2]);
            }

            $this->origins[] = $origin;
        } else {
            throw DistanceMatrixException::invalidDistanceMatrixRequestOrigin();
        }
    }

public function addOrigin ( ) { $ args = func_get_args ( ) ; if ( isset ( $ args [ 0 ] ) && is_string ( $ args [ 0 ] ) ) { $ this -> origins [ ] = $ args [ 0 ] ; } elseif ( isset ( $ args [ 0 ] ) && ( $ args [ 0 ] instanceof Coordinate ) ) { $ this -> origins [ ] = $ args [ 0 ] ; } elseif ( ( isset ( $ args [ 0 ] ) && is_numeric ( $ args [ 0 ] ) ) && ( isset ( $ args [ 1 ] ) && is_numeric ( $ args [ 1 ] ) ) ) { $ origin = new Coordinate ( ) ; $ origin -> setLatitude ( $ args [ 0 ] ) ; $ origin -> setLongitude ( $ args [ 1 ] ) ; if ( isset ( $ args [ 2 ] ) && is_bool ( $ args [ 2 ] ) ) { $ origin -> setNoWrap ( $ args [ 2 ] ) ; } $ this -> origins [ ] = $ origin ; } else { throw DistanceMatrixException :: invalidDistanceMatrixRequestOrigin ( ) ; } }

Adds an origin to the request.

Available prototypes:
- function addOrigin(string $destination)
- function addOrigin(Ivory\GoogleMap\Base\Coordinate $destination)
- function addOrigin(double $latitude, double $longitude, boolean $noWrap)

@throws \Ivory\GoogleMap\Exception\DistanceMatrixException If the origin is not valid (prototypes).


public function setRegion($region = null)
    {
        if ((!is_string($region) || (strlen($region) !== 2)) && ($region !== null)) {
            throw DistanceMatrixException::invalidDistanceMatrixRequestRegion();
        }

        $this->region = $region;
    }

public function setRegion ( $ region = null ) { if ( ( ! is_string ( $ region ) || ( strlen ( $ region ) !== 2 ) ) && ( $ region !== null ) ) { throw DistanceMatrixException :: invalidDistanceMatrixRequestRegion ( ) ; } $ this -> region = $ region ; }

Sets the distance matrix request region.

@param string $region The distance matrix request region.

@throws \Ivory\GoogleMap\Exception\DistanceMatrixException If the region is not valid.

Sets the distance matrix request region .


public function setLanguage($language = null)
    {
        if ((!is_string($language) || ((strlen($language) !== 2) && (strlen($language) !== 5))) && ($language !== null)) {
            throw DistanceMatrixException::invalidDistanceMatrixRequestLanguage();
        }

        $this->language = $language;
    }

public function setLanguage ( $ language = null ) { if ( ( ! is_string ( $ language ) || ( ( strlen ( $ language ) !== 2 ) && ( strlen ( $ language ) !== 5 ) ) ) && ( $ language !== null ) ) { throw DistanceMatrixException :: invalidDistanceMatrixRequestLanguage ( ) ; } $ this -> language = $ language ; }

Sets the distance matrix request language.

@param string $language The distance matrix request language.

@throws \Ivory\GoogleMap\Exception\DistanceMatrixException If the language is not valid.

Sets the distance matrix request language .


public function setTravelMode($travelMode = null)
    {
        $travelModes = array_diff(TravelMode::getTravelModes(), array(TravelMode::TRANSIT));

        if (!in_array($travelMode, $travelModes) && ($travelMode !== null)) {
            throw DistanceMatrixException::invalidDistanceMatrixRequestTravelMode();
        }

        $this->travelMode = $travelMode;
    }

public function setTravelMode ( $ travelMode = null ) { $ travelModes = array_diff ( TravelMode :: getTravelModes ( ) , array ( TravelMode :: TRANSIT ) ) ; if ( ! in_array ( $ travelMode , $ travelModes ) && ( $ travelMode !== null ) ) { throw DistanceMatrixException :: invalidDistanceMatrixRequestTravelMode ( ) ; } $ this -> travelMode = $ travelMode ; }

Sets the distance matrix request travel mode.

@param string $travelMode The distance matrix request travel mode.

@throws \Ivory\GoogleMap\Exception\DistanceMatrixException If the travel mode is not valid.

Sets the distance matrix request travel mode .


public function setUnitSystem($unitSystem = null)
    {
        if (!in_array($unitSystem, UnitSystem::getUnitSystems()) && ($unitSystem !== null)) {
            throw DistanceMatrixException::invalidDistanceMatrixRequestUnitSystem();
        }

        $this->unitSystem = $unitSystem;
    }

public function setUnitSystem ( $ unitSystem = null ) { if ( ! in_array ( $ unitSystem , UnitSystem :: getUnitSystems ( ) ) && ( $ unitSystem !== null ) ) { throw DistanceMatrixException :: invalidDistanceMatrixRequestUnitSystem ( ) ; } $ this -> unitSystem = $ unitSystem ; }

Sets  the distance matrix request unit system.

@param string $unitSystem The distance matrix request unit system.

@throws \Ivory\GoogleMap\Exception\DistanceMatrixException If the unit system is not valid.

Sets the distance matrix request unit system .


public static function getControlPositions()
    {
        return array(
            self::BOTTOM_CENTER,
            self::BOTTOM_LEFT,
            self::BOTTOM_RIGHT,
            self::LEFT_BOTTOM,
            self::LEFT_CENTER,
            self::LEFT_TOP,
            self::RIGHT_BOTTOM,
            self::RIGHT_CENTER,
            self::RIGHT_TOP,
            self::TOP_CENTER,
            self::TOP_LEFT,
            self::TOP_RIGHT,
        );
    }

public static function getControlPositions ( ) { return array ( self :: BOTTOM_CENTER , self :: BOTTOM_LEFT , self :: BOTTOM_RIGHT , self :: LEFT_BOTTOM , self :: LEFT_CENTER , self :: LEFT_TOP , self :: RIGHT_BOTTOM , self :: RIGHT_CENTER , self :: RIGHT_TOP , self :: TOP_CENTER , self :: TOP_LEFT , self :: TOP_RIGHT , ) ; }

Gets the available control positions.

@return array The control positions.


public function setStatus($status)
    {
        if (!in_array($status, DirectionsStatus::getDirectionsStatus())) {
            throw DirectionsException::invalidDirectionsResponseStatus();
        }

        $this->status = $status;
    }

public function setStatus ( $ status ) { if ( ! in_array ( $ status , DirectionsStatus :: getDirectionsStatus ( ) ) ) { throw DirectionsException :: invalidDirectionsResponseStatus ( ) ; } $ this -> status = $ status ; }

Sets the directions response status.

@param string $status The directions response status.

@throws \Ivory\GoogleMap\Exception\DirectionsException If the status is not valid.


public function render(OverviewMapControl $overviewMapControl)
    {
        return $this->jsonBuilder
            ->reset()
            ->setValue('[opened]', $overviewMapControl->isOpened())
            ->build();
    }

public function render ( OverviewMapControl $ overviewMapControl ) { return $ this -> jsonBuilder -> reset ( ) -> setValue ( '[opened]' , $ overviewMapControl -> isOpened ( ) ) -> build ( ) ; }

Renders an overview map control.

@param \Ivory\GoogleMap\Controls\OverviewMapControl $overviewMapControl The overview map control.

@return string The JS output.


public function render(Bound $bound)
    {
        if ($bound->hasExtends() || !$bound->hasCoordinates()) {
            return sprintf('%s = new google.maps.LatLngBounds();'.PHP_EOL, $bound->getJavascriptVariable());
        }

        return sprintf(
            '%s = new google.maps.LatLngBounds(%s, %s);'.PHP_EOL,
            $bound->getJavascriptVariable(),
            $bound->getSouthWest()->getJavascriptVariable(),
            $bound->getNorthEast()->getJavascriptVariable()
        );
    }

Renders the bound.

@param \Ivory\GoogleMap\Base\Bound $bound The bound.

@return string The JS output.


public function renderExtends(Bound $bound)
    {
        $output = array();

        foreach ($bound->getExtends() as $extend) {
            if (($extend instanceof Marker) || ($extend instanceof InfoWindow)) {
                $output[] = sprintf(
                    '%s.extend(%s.getPosition());'.PHP_EOL,
                    $bound->getJavascriptVariable(),
                    $extend->getJavascriptVariable()
                );
            } elseif (($extend instanceof Polyline)
                || ($extend instanceof EncodedPolyline)
                || ($extend instanceof Polygon)
            ) {
                $output[] = sprintf(
                    '%s.getPath().forEach(function(element){%s.extend(element)});'.PHP_EOL,
                    $extend->getJavascriptVariable(),
                    $bound->getJavascriptVariable()
                );
            } elseif (($extend instanceof Rectangle) || ($extend instanceof GroundOverlay)) {
                $output[] = sprintf(
                    '%s.union(%s);'.PHP_EOL,
                    $bound->getJavascriptVariable(),
                    $extend->getBound()->getJavascriptVariable()
                );
            } elseif ($extend instanceof Circle) {
                $output[] = sprintf(
                    '%s.union(%s.getBounds());'.PHP_EOL,
                    $bound->getJavascriptVariable(),
                    $extend->getJavascriptVariable()
                );
            }
        }

        return implode('', $output);
    }

Renders the bound's extend of a marker.

@param \Ivory\GoogleMap\Base\Bound $bound The bound.

@return string The JS output.

Renders the bound s extend of a marker .


protected function printAllStatistics()
    {
        $longest_label_chars = 0; // Initialize.

        foreach ($this->stats as $_label => $_value) {
            $longest_label_chars = max($longest_label_chars, mb_strlen($_label));
        }
        echo "\n\n"; // Two lines down...
        echo '- Benchmark ----------------------------------------'."\n";

        $statistics = ''; // Initialize.

        foreach ($this->stats as $_label => $_value) {
            $_label_chars     = mb_strlen($_label);
            $_alignment_chars = $longest_label_chars - $_label_chars;
            $statistics .= $_label.':    '.str_repeat(' ', $_alignment_chars).$_value."\n";
        } // unset($_label_chars, $_alignment_chars);

        echo $this->c::mbTrim($statistics)."\n";

        echo '----------------------------------------------------'."\n\n";
    }

Print statistics.

@since 150424 Benchmarking.


public function setMarkers($markers)
    {
        $this->markers = array();

        foreach ($markers as $marker) {
            $this->addMarker($marker);
        }
    }

public function setMarkers ( $ markers ) { $ this -> markers = array ( ) ; foreach ( $ markers as $ marker ) { $ this -> addMarker ( $ marker ) ; } }

Sets the cluster markers.

@param array $markers The cluster markers.


public function setHelpers(array $helpers)
    {
        $this->helpers = array();

        foreach ($helpers as $name => $helper) {
            $this->setHelper($name, $helper);
        }
    }

public function setHelpers ( array $ helpers ) { $ this -> helpers = array ( ) ; foreach ( $ helpers as $ name => $ helper ) { $ this -> setHelper ( $ name , $ helper ) ; } }

Sets the marker cluster helper helpers.

@param array $helpers The marker cluster helper helpers.

Sets the marker cluster helper helpers .


public function getHelper($name)
    {
        if (!$this->hasHelper($name)) {
            throw HelperException::invalidMarkerClusterHelper();
        }

        return $this->helpers[$name];
    }

public function getHelper ( $ name ) { if ( ! $ this -> hasHelper ( $ name ) ) { throw HelperException :: invalidMarkerClusterHelper ( ) ; } return $ this -> helpers [ $ name ] ; }

Gets a specific marker cluster helper.

@param string $name The marker cluster type.

@throws \Ivory\GoogleMap\Exception\HelperException If the helper does not exist.

@return \Ivory\GoogleMap\Helper\Overlays\MarkerCluster\MarkerClusterHelperInterface The marker cluster helper.


public function setExtensionHelpers(array $extensionHelpers)
    {
        $this->extensionHelpers = array();

        foreach ($extensionHelpers as $name => $extensionHelper) {
            $this->setExtensionHelper($name, $extensionHelper);
        }
    }

public function setExtensionHelpers ( array $ extensionHelpers ) { $ this -> extensionHelpers = array ( ) ; foreach ( $ extensionHelpers as $ name => $ extensionHelper ) { $ this -> setExtensionHelper ( $ name , $ extensionHelper ) ; } }

Sets the map extension helpers.

@param array $extensionHelpers The map extension helpers.


public function getExtensionHelper($name)
    {
        if (!$this->hasExtensionHelper($name)) {
            throw HelperException::invalidExtension($name);
        }

        return $this->extensionHelpers[$name];
    }

public function getExtensionHelper ( $ name ) { if ( ! $ this -> hasExtensionHelper ( $ name ) ) { throw HelperException :: invalidExtension ( $ name ) ; } return $ this -> extensionHelpers [ $ name ] ; }

Gets a specific extension helper.

@param string $name The extension helper name.

@throws \Ivory\GoogleMap\Exception\HelperException If the extension helper does not exist.

@return \Ivory\GoogleMap\Helper\Extension\ExtensionHelperInterface The extension helper.


public function removeExtensionHelper($name)
    {
        if (!$this->hasExtensionHelper($name)) {
            throw HelperException::invalidExtension($name);
        }

        unset($this->extensionHelpers[$name]);
    }

public function removeExtensionHelper ( $ name ) { if ( ! $ this -> hasExtensionHelper ( $ name ) ) { throw HelperException :: invalidExtension ( $ name ) ; } unset ( $ this -> extensionHelpers [ $ name ] ) ; }

Removes an extension helper.

@param string $name The extension helper name.

@throws \Ivory\GoogleMap\Exception\HelperException If the extension helper does not exist.


public function renderHtmlContainer(Map $map)
    {
        return sprintf(
            '

'.PHP_EOL,
            $map->getHtmlContainerId(),
            $map->getStylesheetOption('width'),
            $map->getStylesheetOption('height')
        );
    }

Renders the map container.

@param \Ivory\GoogleMap\Map $map The map.

@return string The HTML output.


public function renderStylesheets(Map $map)
    {
        $html = array();

        $html[] = '<style type="text/css" scoped>'.PHP_EOL;
        $html[] = '#'.$map->getHtmlContainerId().'{'.PHP_EOL;

        foreach ($map->getStylesheetOptions() as $option => $value) {
            $html[] = $option.':'.$value.';'.PHP_EOL;
        }

        $html[] = '}'.PHP_EOL;
        $html[] = '</style>'.PHP_EOL;

        return implode('', $html);
    }

public
function
renderStylesheets
(
Map
$
map
)
{
$
html
=
array
(
)
;
$
html
[
]
=
'<style type="text/css" scoped>'
.
PHP_EOL
;
$
html
[
]
=
'#'
.
$
map
->
getHtmlContainerId
(
)
.
'{'
.
PHP_EOL
;
foreach
(
$
map
->
getStylesheetOptions
(
)
as
$
option
=>
$
value
)
{
$
html
[
]
=
$
option
.
':'
.
$
value
.
';'
.
PHP_EOL
;
}
$
html
[
]
=
'}'
.
PHP_EOL
;
$
html
[
]
=
'</style>'
.
PHP_EOL
;
return
implode
(
''
,
$
html
)
;
}

Renders the html map stylesheets.

@param \Ivory\GoogleMap\Map $map The map.

@return string The HTML output.


public function renderJavascripts(Map $map)
    {
        $output = array();

        if (!$map->isAsync()) {
            $output[] = $this->renderJsLibraries($map);
        }

        $output[] = '<script type="text/javascript">'.PHP_EOL;
        $output[] = $this->renderJsBefore($map);
        $output[] = $this->renderJsContainer($map);
        $output[] = $this->renderJsAfter($map);
        $output[] = '</script>'.PHP_EOL;

        if ($map->isAsync()) {
            $output[] = $this->renderJsLibraries($map);
        }

        return implode('', $output);
    }

public
function
renderJavascripts
(
Map
$
map
)
{
$
output
=
array
(
)
;
if
(
!
$
map
->
isAsync
(
)
)
{
$
output
[
]
=
$
this
->
renderJsLibraries
(
$
map
)
;
}
$
output
[
]
=
'<script type="text/javascript">'
.
PHP_EOL
;
$
output
[
]
=
$
this
->
renderJsBefore
(
$
map
)
;
$
output
[
]
=
$
this
->
renderJsContainer
(
$
map
)
;
$
output
[
]
=
$
this
->
renderJsAfter
(
$
map
)
;
$
output
[
]
=
'</script>'
.
PHP_EOL
;
if
(
$
map
->
isAsync
(
)
)
{
$
output
[
]
=
$
this
->
renderJsLibraries
(
$
map
)
;
}
return
implode
(
''
,
$
output
)
;
}

Renders the map javascripts.

@param \Ivory\GoogleMap\Map $map The map.

@return string The HTML output.


public function renderJsLibraries(Map $map)
    {
        $output = array();

        foreach ($this->getExtensionHelpers() as $extension) {
            $output[] = $extension->renderLibraries($map);
        }

        return implode('', $output);
    }

public function renderJsLibraries ( Map $ map ) { $ output = array ( ) ; foreach ( $ this -> getExtensionHelpers ( ) as $ extension ) { $ output [ ] = $ extension -> renderLibraries ( $ map ) ; } return implode ( '' , $ output ) ; }

Renders the javascript libraries.

@param \Ivory\GoogleMap\Map $map The map.

@return string The HTML output.


public function renderJsBefore(Map $map)
    {
        $output = array();

        foreach ($this->getExtensionHelpers() as $extension) {
            $output[] = $extension->renderBefore($map);
        }

        return implode('', $output);
    }

public function renderJsBefore ( Map $ map ) { $ output = array ( ) ; foreach ( $ this -> getExtensionHelpers ( ) as $ extension ) { $ output [ ] = $ extension -> renderBefore ( $ map ) ; } return implode ( '' , $ output ) ; }

Renders JS code just before the generated one.

@param \Ivory\GoogleMap\Map $map The map.

@return string The JS output.

Renders JS code just before the generated one .


public function renderJsAfter(Map $map)
    {
        $output = array();

        foreach (array_reverse($this->getExtensionHelpers()) as $extension) {
            $output[] = $extension->renderAfter($map);
        }

        return implode('', $output);
    }

public function renderJsAfter ( Map $ map ) { $ output = array ( ) ; foreach ( array_reverse ( $ this -> getExtensionHelpers ( ) ) as $ extension ) { $ output [ ] = $ extension -> renderAfter ( $ map ) ; } return implode ( '' , $ output ) ; }

Renders JS code just after the generated one.

@param \Ivory\GoogleMap\Map $map The map.

@return string The JS output.

Renders JS code just after the generated one .


public function renderJsContainer(Map $map)
    {
        $output = array();

        $output[] = $this->renderJsContainerInit($map);

        $output[] = $this->renderJsContainerCoordinates($map);
        $output[] = $this->renderJsContainerBounds($map);
        $output[] = $this->renderJsContainerPoints($map);
        $output[] = $this->renderJsContainerSizes($map);

        $output[] = $this->renderJsContainerMap($map);

        $output[] = $this->renderJsContainerCircles($map);
        $output[] = $this->renderJsContainerEncodedPolylines($map);
        $output[] = $this->renderJsContainerGroundOverlays($map);
        $output[] = $this->renderJsContainerPolygons($map);
        $output[] = $this->renderJsContainerPolylines($map);
        $output[] = $this->renderJsContainerRectangles($map);
        $output[] = $this->renderJsContainerInfoWindows($map);
        $output[] = $this->renderJsContainerMarkerImages($map);
        $output[] = $this->renderJsContainerMarkerShapes($map);
        $output[] = $this->renderJsContainerMarkerCluster($map);

        $output[] = $this->renderJsContainerKMLLayers($map);

        $output[] = $this->renderJsContainerEventManager($map);

        $output[] = $this->renderJsContainerExtra($map);

        return implode('', $output);
    }

public function renderJsContainer ( Map $ map ) { $ output = array ( ) ; $ output [ ] = $ this -> renderJsContainerInit ( $ map ) ; $ output [ ] = $ this -> renderJsContainerCoordinates ( $ map ) ; $ output [ ] = $ this -> renderJsContainerBounds ( $ map ) ; $ output [ ] = $ this -> renderJsContainerPoints ( $ map ) ; $ output [ ] = $ this -> renderJsContainerSizes ( $ map ) ; $ output [ ] = $ this -> renderJsContainerMap ( $ map ) ; $ output [ ] = $ this -> renderJsContainerCircles ( $ map ) ; $ output [ ] = $ this -> renderJsContainerEncodedPolylines ( $ map ) ; $ output [ ] = $ this -> renderJsContainerGroundOverlays ( $ map ) ; $ output [ ] = $ this -> renderJsContainerPolygons ( $ map ) ; $ output [ ] = $ this -> renderJsContainerPolylines ( $ map ) ; $ output [ ] = $ this -> renderJsContainerRectangles ( $ map ) ; $ output [ ] = $ this -> renderJsContainerInfoWindows ( $ map ) ; $ output [ ] = $ this -> renderJsContainerMarkerImages ( $ map ) ; $ output [ ] = $ this -> renderJsContainerMarkerShapes ( $ map ) ; $ output [ ] = $ this -> renderJsContainerMarkerCluster ( $ map ) ; $ output [ ] = $ this -> renderJsContainerKMLLayers ( $ map ) ; $ output [ ] = $ this -> renderJsContainerEventManager ( $ map ) ; $ output [ ] = $ this -> renderJsContainerExtra ( $ map ) ; return implode ( '' , $ output ) ; }

Renders the javascript container.

@param \Ivory\GoogleMap\Map $map The map.

@return string The JS output.


public function renderJsContainerCoordinates(Map $map)
    {
        $output = array();

        foreach ($this->computeCoordinates($map) as $coordinate) {
            $output[] = sprintf(
                '%s.coordinates.%s = %s',
                $this->getJsContainerName($map),
                $coordinate->getJavascriptVariable(),
                $this->coordinateHelper->render($coordinate)
            );
        }

        return implode('', $output);
    }

public
function
renderJsContainerCoordinates
(
Map
$
map
)
{
$
output
=
array
(
)
;
foreach
(
$
this
->
computeCoordinates
(
$
map
)
as
$
coordinate
)
{
$
output
[
]
=
sprintf
(
'%s.coordinates.%s = %s'
,
$
this
->
getJsContainerName
(
$
map
)
,
$
coordinate
->
getJavascriptVariable
(
)
,
$
this
->
coordinateHelper
->
render
(
$
coordinate
)
)
;
}
return
implode
(
''
,
$
output
)
;
}

Renders the javascript container coordinates.

@param \Ivory\GoogleMap\Map $map The map.

@return string The JS output.

Renders the javascript container coordinates .


public function renderJsContainerBounds(Map $map)
    {
        $output = array();

        foreach ($this->computeBounds($map) as $bound) {
            $output[] = sprintf(
                '%s.bounds.%s = %s',
                $this->getJsContainerName($map),
                $bound->getJavascriptVariable(),
                $this->boundHelper->render($bound)
            );
        }

        return implode('', $output);
    }

public
function
renderJsContainerBounds
(
Map
$
map
)
{
$
output
=
array
(
)
;
foreach
(
$
this
->
computeBounds
(
$
map
)
as
$
bound
)
{
$
output
[
]
=
sprintf
(
'%s.bounds.%s = %s'
,
$
this
->
getJsContainerName
(
$
map
)
,
$
bound
->
getJavascriptVariable
(
)
,
$
this
->
boundHelper
->
render
(
$
bound
)
)
;
}
return
implode
(
''
,
$
output
)
;
}

Renders the javascript container bounds.

@param \Ivory\GoogleMap\Map $map The map.

@return string The JS output.

Renders the javascript container bounds .


public function renderJsContainerPoints(Map $map)
    {
        $output = array();

        foreach ($this->computePoints($map) as $point) {
            $output[] = sprintf(
                '%s.points.%s = %s',
                $this->getJsContainerName($map),
                $point->getJavascriptVariable(),
                $this->pointHelper->render($point)
            );
        }

        return implode('', $output);
    }

public
function
renderJsContainerPoints
(
Map
$
map
)
{
$
output
=
array
(
)
;
foreach
(
$
this
->
computePoints
(
$
map
)
as
$
point
)
{
$
output
[
]
=
sprintf
(
'%s.points.%s = %s'
,
$
this
->
getJsContainerName
(
$
map
)
,
$
point
->
getJavascriptVariable
(
)
,
$
this
->
pointHelper
->
render
(
$
point
)
)
;
}
return
implode
(
''
,
$
output
)
;
}

Renders the javascript container points.

@param \Ivory\GoogleMap\Map $map The map.

@return string The JS output.

Renders the javascript container points .


public function renderJsContainerSizes(Map $map)
    {
        $output = array();

        foreach ($this->computeSizes($map) as $size) {
            $output[] = sprintf(
                '%s.sizes.%s = %s',
                $this->getJsContainerName($map),
                $size->getJavascriptVariable(),
                $this->sizeHelper->render($size)
            );
        }

        return implode('', $output);
    }

public
function
renderJsContainerSizes
(
Map
$
map
)
{
$
output
=
array
(
)
;
foreach
(
$
this
->
computeSizes
(
$
map
)
as
$
size
)
{
$
output
[
]
=
sprintf
(
'%s.sizes.%s = %s'
,
$
this
->
getJsContainerName
(
$
map
)
,
$
size
->
getJavascriptVariable
(
)
,
$
this
->
sizeHelper
->
render
(
$
size
)
)
;
}
return
implode
(
''
,
$
output
)
;
}

Renders the javascript container sizes.

@param \Ivory\GoogleMap\Map $map The map.

@return string The JS output.

Renders the javascript container sizes .


public function renderJsContainerMap(Map $map)
    {
        return sprintf('%s.map = %s', $this->getJsContainerName($map), $this->renderMap($map));
    }

public
function
renderJsContainerMap
(
Map
$
map
)
{
return
sprintf
(
'%s.map = %s'
,
$
this
->
getJsContainerName
(
$
map
)
,
$
this
->
renderMap
(
$
map
)
)
;
}

Renders the javascript container map.

@param \Ivory\GoogleMap\Map $map The map.

@return string The JS output.


public function renderJsContainerCircles(Map $map)
    {
        $output = array();

        foreach ($map->getCircles() as $circle) {
            $output[] = sprintf(
                '%s.circles.%s = %s',
                $this->getJsContainerName($map),
                $circle->getJavascriptVariable(),
                $this->circleHelper->render($circle, $map)
            );
        }

        return implode('', $output);
    }

public
function
renderJsContainerCircles
(
Map
$
map
)
{
$
output
=
array
(
)
;
foreach
(
$
map
->
getCircles
(
)
as
$
circle
)
{
$
output
[
]
=
sprintf
(
'%s.circles.%s = %s'
,
$
this
->
getJsContainerName
(
$
map
)
,
$
circle
->
getJavascriptVariable
(
)
,
$
this
->
circleHelper
->
render
(
$
circle
,
$
map
)
)
;
}
return
implode
(
''
,
$
output
)
;
}

Renders the javascript container circles.

@param \Ivory\GoogleMap\Map $map The map.

@return string The JS output.

Renders the javascript container circles .


public function renderJsContainerEncodedPolylines(Map $map)
    {
        $output = array();

        foreach ($map->getEncodedPolylines() as $encodedPolyline) {
            $output[] = sprintf(
                '%s.encoded_polylines.%s = %s',
                $this->getJsContainerName($map),
                $encodedPolyline->getJavascriptVariable(),
                $this->encodedPolylineHelper->render($encodedPolyline, $map)
            );
        }

        return implode('', $output);
    }

public
function
renderJsContainerEncodedPolylines
(
Map
$
map
)
{
$
output
=
array
(
)
;
foreach
(
$
map
->
getEncodedPolylines
(
)
as
$
encodedPolyline
)
{
$
output
[
]
=
sprintf
(
'%s.encoded_polylines.%s = %s'
,
$
this
->
getJsContainerName
(
$
map
)
,
$
encodedPolyline
->
getJavascriptVariable
(
)
,
$
this
->
encodedPolylineHelper
->
render
(
$
encodedPolyline
,
$
map
)
)
;
}
return
implode
(
''
,
$
output
)
;
}

Renders the javascript container encoded polylines.

@param \Ivory\GoogleMap\Map $map The map.

@return string The JS output.

Renders the javascript container encoded polylines .


public function renderJsContainerGroundOverlays(Map $map)
    {
        $output = array();

        foreach ($map->getGroundOverlays() as $groundOverlay) {
            $output[] = sprintf(
                '%s.ground_overlays.%s = %s',
                $this->getJsContainerName($map),
                $groundOverlay->getJavascriptVariable(),
                $this->groundOverlayHelper->render($groundOverlay, $map)
            );
        }

        return implode('', $output);
    }

public
function
renderJsContainerGroundOverlays
(
Map
$
map
)
{
$
output
=
array
(
)
;
foreach
(
$
map
->
getGroundOverlays
(
)
as
$
groundOverlay
)
{
$
output
[
]
=
sprintf
(
'%s.ground_overlays.%s = %s'
,
$
this
->
getJsContainerName
(
$
map
)
,
$
groundOverlay
->
getJavascriptVariable
(
)
,
$
this
->
groundOverlayHelper
->
render
(
$
groundOverlay
,
$
map
)
)
;
}
return
implode
(
''
,
$
output
)
;
}

Renders the javascript container ground overlays.

@param \Ivory\GoogleMap\Map $map The map.

@return string The JS output.

Renders the javascript container ground overlays .


public function renderJsContainerPolygons(Map $map)
    {
        $output = array();

        foreach ($map->getPolygons() as $polygon) {
            $output[] = sprintf(
                '%s.polygons.%s = %s',
                $this->getJsContainerName($map),
                $polygon->getJavascriptVariable(),
                $this->polygonHelper->render($polygon, $map)
            );
        }

        return implode('', $output);
    }

public
function
renderJsContainerPolygons
(
Map
$
map
)
{
$
output
=
array
(
)
;
foreach
(
$
map
->
getPolygons
(
)
as
$
polygon
)
{
$
output
[
]
=
sprintf
(
'%s.polygons.%s = %s'
,
$
this
->
getJsContainerName
(
$
map
)
,
$
polygon
->
getJavascriptVariable
(
)
,
$
this
->
polygonHelper
->
render
(
$
polygon
,
$
map
)
)
;
}
return
implode
(
''
,
$
output
)
;
}

Renders the javascript container polygons.

@param \Ivory\GoogleMap\Map $map The map.

@return string The JS output.

Renders the javascript container polygons .


public function renderJsContainerPolylines(Map $map)
    {
        $output = array();

        foreach ($map->getPolylines() as $polyline) {
            $output[] = sprintf(
                '%s.polylines.%s = %s',
                $this->getJsContainerName($map),
                $polyline->getJavascriptVariable(),
                $this->polylineHelper->render($polyline, $map)
            );
        }

        return implode('', $output);
    }

public
function
renderJsContainerPolylines
(
Map
$
map
)
{
$
output
=
array
(
)
;
foreach
(
$
map
->
getPolylines
(
)
as
$
polyline
)
{
$
output
[
]
=
sprintf
(
'%s.polylines.%s = %s'
,
$
this
->
getJsContainerName
(
$
map
)
,
$
polyline
->
getJavascriptVariable
(
)
,
$
this
->
polylineHelper
->
render
(
$
polyline
,
$
map
)
)
;
}
return
implode
(
''
,
$
output
)
;
}

Renders the javascript container polylines.

@param \Ivory\GoogleMap\Map $map The map.

@return string The JS output.

Renders the javascript container polylines .


public function renderJsContainerRectangles(Map $map)
    {
        $output = array();

        foreach ($map->getRectangles() as $rectangle) {
            $output[] = sprintf(
                '%s.rectangles.%s = %s',
                $this->getJsContainerName($map),
                $rectangle->getJavascriptVariable(),
                $this->rectangleHelper->render($rectangle, $map)
            );
        }

        return implode('', $output);
    }

public
function
renderJsContainerRectangles
(
Map
$
map
)
{
$
output
=
array
(
)
;
foreach
(
$
map
->
getRectangles
(
)
as
$
rectangle
)
{
$
output
[
]
=
sprintf
(
'%s.rectangles.%s = %s'
,
$
this
->
getJsContainerName
(
$
map
)
,
$
rectangle
->
getJavascriptVariable
(
)
,
$
this
->
rectangleHelper
->
render
(
$
rectangle
,
$
map
)
)
;
}
return
implode
(
''
,
$
output
)
;
}

Renders the javascript container rectangles.

@param \Ivory\GoogleMap\Map $map The map.

@return string The JS output.

Renders the javascript container rectangles .


public function renderJsContainerInfoWindows(Map $map)
    {
        $output = array();

        $mapInfoWindows = $map->getInfoWindows();
        $markerInfoWindows = $this->computeMarkerInfoWindows($map);

        foreach ($mapInfoWindows as $mapInfoWindow) {
            $output[] = sprintf(
                '%s.info_windows.%s = %s',
                $this->getJsContainerName($map),
                $mapInfoWindow->getJavascriptVariable(),
                $this->infoWindowHelper->render($mapInfoWindow)
            );
        }

        foreach ($markerInfoWindows as $markerInfoWindow) {
            $output[] = sprintf(
                '%s.info_windows.%s = %s',
                $this->getJsContainerName($map),
                $markerInfoWindow->getJavascriptVariable(),
                $this->infoWindowHelper->render($markerInfoWindow, false)
            );
        }

        foreach (array_merge($mapInfoWindows, $markerInfoWindows) as $infoWindow) {
            if ($infoWindow->isAutoClose()) {
                $output[] = sprintf(
                    '%s.closable_info_windows.%s = %s;'.PHP_EOL,
                    $this->getJsContainerName($map),
                    $infoWindow->getJavascriptVariable(),
                    $infoWindow->getJavascriptVariable()
                );
            }
        }

        return implode('', $output);
    }

public
function
renderJsContainerInfoWindows
(
Map
$
map
)
{
$
output
=
array
(
)
;
$
mapInfoWindows
=
$
map
->
getInfoWindows
(
)
;
$
markerInfoWindows
=
$
this
->
computeMarkerInfoWindows
(
$
map
)
;
foreach
(
$
mapInfoWindows
as
$
mapInfoWindow
)
{
$
output
[
]
=
sprintf
(
'%s.info_windows.%s = %s'
,
$
this
->
getJsContainerName
(
$
map
)
,
$
mapInfoWindow
->
getJavascriptVariable
(
)
,
$
this
->
infoWindowHelper
->
render
(
$
mapInfoWindow
)
)
;
}
foreach
(
$
markerInfoWindows
as
$
markerInfoWindow
)
{
$
output
[
]
=
sprintf
(
'%s.info_windows.%s = %s'
,
$
this
->
getJsContainerName
(
$
map
)
,
$
markerInfoWindow
->
getJavascriptVariable
(
)
,
$
this
->
infoWindowHelper
->
render
(
$
markerInfoWindow
,
false
)
)
;
}
foreach
(
array_merge
(
$
mapInfoWindows
,
$
markerInfoWindows
)
as
$
infoWindow
)
{
if
(
$
infoWindow
->
isAutoClose
(
)
)
{
$
output
[
]
=
sprintf
(
'%s.closable_info_windows.%s = %s;'
.
PHP_EOL
,
$
this
->
getJsContainerName
(
$
map
)
,
$
infoWindow
->
getJavascriptVariable
(
)
,
$
infoWindow
->
getJavascriptVariable
(
)
)
;
}
}
return
implode
(
''
,
$
output
)
;
}

Renders the javascript container info windows.

@param \Ivory\GoogleMap\Map $map The map.

@return string The JS output.

Renders the javascript container info windows .


public function renderJsContainerMarkerImages(Map $map)
    {
        $output = array();

        foreach ($this->computeMarkerImages($map) as $markerImage) {
            $output[] = sprintf(
                '%s.marker_images.%s = %s',
                $this->getJsContainerName($map),
                $markerImage->getJavascriptVariable(),
                $this->markerImageHelper->render($markerImage)
            );
        }

        return implode('', $output);
    }

public
function
renderJsContainerMarkerImages
(
Map
$
map
)
{
$
output
=
array
(
)
;
foreach
(
$
this
->
computeMarkerImages
(
$
map
)
as
$
markerImage
)
{
$
output
[
]
=
sprintf
(
'%s.marker_images.%s = %s'
,
$
this
->
getJsContainerName
(
$
map
)
,
$
markerImage
->
getJavascriptVariable
(
)
,
$
this
->
markerImageHelper
->
render
(
$
markerImage
)
)
;
}
return
implode
(
''
,
$
output
)
;
}

Renders the javascript container maker images.

@param \Ivory\GoogleMap\Map $map The map.

@return string The JS output.

Renders the javascript container maker images .


public function renderJsContainerMarkerShapes(Map $map)
    {
        $output = array();

        foreach ($this->computeMarkerShapes($map) as $markerShape) {
            $output[] = sprintf(
                '%s.marker_shapes.%s = %s',
                $this->getJsContainerName($map),
                $markerShape->getJavascriptVariable(),
                $this->markerShapeHelper->render($markerShape)
            );
        }

        return implode('', $output);
    }

public
function
renderJsContainerMarkerShapes
(
Map
$
map
)
{
$
output
=
array
(
)
;
foreach
(
$
this
->
computeMarkerShapes
(
$
map
)
as
$
markerShape
)
{
$
output
[
]
=
sprintf
(
'%s.marker_shapes.%s = %s'
,
$
this
->
getJsContainerName
(
$
map
)
,
$
markerShape
->
getJavascriptVariable
(
)
,
$
this
->
markerShapeHelper
->
render
(
$
markerShape
)
)
;
}
return
implode
(
''
,
$
output
)
;
}

Renders the javascript container marker shapes.

@param \Ivory\GoogleMap\Map $map The map.

@return string The JS output.

Renders the javascript container marker shapes .