protected static function getArgumentDeclaration(\ReflectionMethod $method)
    {
        $declarations = array();
        $parameters = explode(', ', self::getMethodParameters($method));

        foreach ($parameters as $parameter) {

            if (0 < strpos(trim($parameter), ' $') && false === strpos($parameter, 'array')) {
                $declarations[] = '\\' . $parameter;
                continue;
            }

            $declarations[] = $parameter;
        }

        return implode(', ', $declarations);
    }

protected
static
function
getArgumentDeclaration
(
\
ReflectionMethod
$
method
)
{
$
declarations
=
array
(
)
;
$
parameters
=
explode
(
', '
,
self
::
getMethodParameters
(
$
method
)
)
;
foreach
(
$
parameters
as
$
parameter
)
{
if
(
0
<
strpos
(
trim
(
$
parameter
)
,
' $'
)
&&
false
===
strpos
(
$
parameter
,
'array'
)
)
{
$
declarations
[
]
=
'\\'
.
$
parameter
;
continue
;
}
$
declarations
[
]
=
$
parameter
;
}
return
implode
(
', '
,
$
declarations
)
;
}

Adds prefix for global namespace to the type hint of each parameter of the method.

This method is only necessary 'cause PHPUnit is currently not able to detect the usage of
namespaces. Thus it does not add the '\' to a type hint.

@param \ReflectionMethod $method

@return string

Adds prefix for global namespace to the type hint of each parameter of the method .


protected static function canProxyMethod(\ReflectionMethod $method)
    {
        if ($method->isConstructor() || $method->isFinal() || $method->isStatic() || isset(self::$blacklistedMethodNames[$method->getName()])
        ) {
            return false;
        } elseif ($method->isProtected()) {
            return true;
        }

        return false;
    }

protected static function canProxyMethod ( \ ReflectionMethod $ method ) { if ( $ method -> isConstructor ( ) || $ method -> isFinal ( ) || $ method -> isStatic ( ) || isset ( self :: $ blacklistedMethodNames [ $ method -> getName ( ) ] ) ) { return false ; } elseif ( $ method -> isProtected ( ) ) { return true ; } return false ; }

Determine if the given method may be proxied.

Since it is not possible to reflect a
- constructor
- final method
- static method
those will cause this method to return false.
Also methods registered in the blacklist will cause this
method to return false.

@param \ReflectionMethod $method Name of the method to be reflected.

@return boolean True, if the given method may be reflected, else false.

Determine if the given method may be proxied .


protected static function canProxyMethods(array $methods)
    {
        $proxyMethods = array();

        foreach ($methods as $method) {
            if (self::canProxyMethod($method)) {
                $proxyMethods[] = $method;
            }
        }

        return $proxyMethods;
    }

protected static function canProxyMethods ( array $ methods ) { $ proxyMethods = array ( ) ; foreach ( $ methods as $ method ) { if ( self :: canProxyMethod ( $ method ) ) { $ proxyMethods [ ] = $ method ; } } return $ proxyMethods ; }

Filters the list of ReflectionMethods down to those actually proxyable.

Proxyable methods are those which are NOT:
- constructor
- final method
- static method
- members of the self::blacklist

@param array $methods

@return \ReflectionMethod[]

Filters the list of ReflectionMethods down to those actually proxyable .


protected static function traverseStructure($iterator)
    {
        $children = '';
        while ($iterator->valid()) {

            if ($iterator->hasChildren()) {
                $current = 'array (' . self::traverseStructure($iterator->getChildren()) . '), ';
            } else {
                $current = "'" . $iterator->current() . "', ";
            }

            $key = $iterator->key();

            if (is_numeric($key)) {
                $children .= $key . " => " . $current;
            } else {
                $children .= "'" . $key . "' => " . $current;
            }

            $iterator->next();
        }

        return $children;
    }

protected
static
function
traverseStructure
(
$
iterator
)
{
$
children
=
''
;
while
(
$
iterator
->
valid
(
)
)
{
if
(
$
iterator
->
hasChildren
(
)
)
{
$
current
=
'array ('
.
self
::
traverseStructure
(
$
iterator
->
getChildren
(
)
)
.
'), '
;
}
else
{
$
current
=
"'"
.
$
iterator
->
current
(
)
.
"', "
;
}
$
key
=
$
iterator
->
key
(
)
;
if
(
is_numeric
(
$
key
)
)
{
$
children
.=
$
key
.
" => "
.
$
current
;
}
else
{
$
children
.=
"'"
.
$
key
.
"' => "
.
$
current
;
}
$
iterator
->
next
(
)
;
}
return
$
children
;
}

Walks recursivly throught an array and concatinates the found info to a string.

@param \RecursiveIterator $iterator

@return string

Walks recursivly throught an array and concatinates the found info to a string .


public static function getMethodParameters($method, $forCall = FALSE)
    {
        $parameters = array();

        foreach ($method->getParameters() as $i => $parameter) {
            $name = '$' . $parameter->getName();

            /* Note: PHP extensions may use empty names for reference arguments
             * or "..." for methods taking a variable number of arguments.
             */
            if ($name === '$' || $name === '$...') {
                $name = '$arg' . $i;
            }

            $default   = '';
            $reference = '';
            $typeHint  = '';

            if (!$forCall) {
                if ($parameter->isArray()) {
                    $typeHint = 'array ';
                }

                else if (version_compare(PHP_VERSION, '5.4.0', '>=') && $parameter->isCallable()) {
                    $typeHint = 'callable ';
                }

                else {
                    try {
                        $class = $parameter->getClass();
                    }

                    catch (\ReflectionException $e) {
                        $class = FALSE;
                    }

                    if ($class) {
                        $typeHint = $class->getName() . ' ';
                    }
                }

                if ($parameter->isDefaultValueAvailable()) {
                    $value   = $parameter->getDefaultValue();
                    $default = ' = ' . var_export($value, TRUE);
                }

                else if ($parameter->isOptional()) {
                    $default = ' = null';
                }

                if ($parameter->isPassedByReference()) {
                    $reference = '&';
                }
            }

            $parameters[] = $typeHint . $reference . $name . $default;
        }

        return join(', ', $parameters);
    }

Returns the parameters of a function or method.

@param  \ReflectionFunction|\ReflectionMethod $method
@param  boolean                             $forCall
@return string
@since  Method available since Release 3.2.0

Returns the parameters of a function or method .


public function create(string $repoName) {
    $this->getGithubAuthentication()->authenticate();
    $this->getHooksApi()->create($this->getGithubUsername(), $repoName, [
      'name' => 'packagist',
      'config' => [
        'user' => $this->getPackagistUser(),
        'token' => $this->getPackagistApiToken()
      ]
    ]);
  }

public function create ( string $ repoName ) { $ this -> getGithubAuthentication ( ) -> authenticate ( ) ; $ this -> getHooksApi ( ) -> create ( $ this -> getGithubUsername ( ) , $ repoName , [ 'name' => 'packagist' , 'config' => [ 'user' => $ this -> getPackagistUser ( ) , 'token' => $ this -> getPackagistApiToken ( ) ] ] ) ; }

Authenticates via the client with github api token and then creates the webhook using the hooks model and the packagist username and api token

@param string $repoName the name of the repository the hook will be created in


protected function loadMessages($category, $language)
    {
        if ($this->enableCaching) {
            $cacheKey = [
                __CLASS__,
                $category,
                $language,
            ];
            return $this->cache
                ->get($cacheKey)
                ->then(function($data) {
                    return $data !== null ? $data : Reaction\Promise\reject(null);
                })->otherwise(function() use ($category, $language, $cacheKey) {
                    $messages = [];
                    return $this->loadMessagesFromDb($category, $language)
                        ->then(function($messagesDb) use (&$messages, $cacheKey) {
                            $messages = $messagesDb;
                            return $this->cache->set($cacheKey, $messagesDb, $this->cachingDuration);
                        })->then(function() use (&$messages) {
                            return $messages;
                        });
                });
        }

        return $this->loadMessagesFromDb($category, $language);
    }

protected function loadMessages ( $ category , $ language ) { if ( $ this -> enableCaching ) { $ cacheKey = [ __CLASS__ , $ category , $ language , ] ; return $ this -> cache -> get ( $ cacheKey ) -> then ( function ( $ data ) { return $ data !== null ? $ data : Reaction \ Promise \ reject ( null ) ; } ) -> otherwise ( function ( ) use ( $ category , $ language , $ cacheKey ) { $ messages = [ ] ; return $ this -> loadMessagesFromDb ( $ category , $ language ) -> then ( function ( $ messagesDb ) use ( & $ messages , $ cacheKey ) { $ messages = $ messagesDb ; return $ this -> cache -> set ( $ cacheKey , $ messagesDb , $ this -> cachingDuration ) ; } ) -> then ( function ( ) use ( & $ messages ) { return $ messages ; } ) ; } ) ; } return $ this -> loadMessagesFromDb ( $ category , $ language ) ; }

Loads the message translation for the specified language and category.
If translation for specific locale code such as `en-US` isn't found it
tries more generic `en`.

@param string $category the message category
@param string $language the target language
@return ExtendedPromiseInterface array the loaded messages. The keys are original messages, and the values
are translated messages.

Loads the message translation for the specified language and category . If translation for specific locale code such as en - US isn t found it tries more generic en .


public function setup(array $config = null, bool $force = false): void
    {
        // If the application was already setup, no need to do it again
        if (self::$setup && false === $force) {
            return;
        }

        // Avoid re-setting up the app later
        self::$setup = true;
        // Set the app static
        self::$app = $this;
        // Ensure the env has been set
        self::setEnv();

        // If the VALKYRJA_START constant hasn't already been set
        if (! \defined('VALKYRJA_START')) {
            // Set a global constant for when the framework started
            \define('VALKYRJA_START', microtime(true));
        }

        // Bootstrap debug capabilities
        $this->bootstrapConfig($config);
        // Bootstrap debug capabilities
        $this->bootstrapDebug();
        // Bootstrap core functionality
        $this->bootstrapCore();
        // Bootstrap the container
        $this->bootstrapContainer();
        // Bootstrap setup
        $this->bootstrapSetup();
        // Bootstrap the timezone
        $this->bootstrapTimezone();
    }

Setup the application.

@param array $config [optional] The config to use
@param bool  $force  [optional] Whether to force a setup

@throws \Valkyrja\Exceptions\InvalidContainerImplementation
@throws \Valkyrja\Exceptions\InvalidDispatcherImplementation
@throws \Valkyrja\Exceptions\InvalidEventsImplementation

@return void


protected function bootstrapConfig(array $config = null): void
    {
        $cacheFilePath = Directory::cachePath('config.php');

        // If we should use the config cache file
        if (is_file($cacheFilePath)) {
            // Get the config from the cache file's contents
            self::$config = require $cacheFilePath;

            return;
        }

        $config         = $config ?? [];
        $configFilePath = Directory::configPath('config.php');
        $configFilePath = is_file($configFilePath)
            ? $configFilePath
            : __DIR__ . '/Config/config.php';
        $defaultConfigs = require $configFilePath;

        self::$config = array_replace_recursive($defaultConfigs, $config);
        /** @var \Valkyrja\Support\Providers\Provider[] $providers */
        $providers = self::$config['providers'];

        foreach ($providers as $provider) {
            // Config providers are NOT deferred and will not follow the
            // deferred value
            $provider::publish($this);
        }
    }

Bootstrap the config.

@param array $config [optional] The config

@return void


protected function bootstrapCore(): void
    {
        // The events class to use from the config
        $eventsImpl = self::$config['app']['events'];
        // The container class to use from the config
        $containerImpl = self::$config['app']['container'];
        // The dispatcher class to use from the config
        $dispatcherImpl = self::$config['app']['dispatcher'];

        // Set the events to a new instance of the events implementation
        self::$events = new $eventsImpl($this);

        // If the events implementation specified does not adhere to the events
        // contract
        if (! self::$events instanceof Events) {
            throw new InvalidEventsImplementation(
                'Invalid Events implementation'
            );
        }

        // Set the container to a new instance of the container implementation
        self::$container = new $containerImpl($this);

        // If the container implementation specified does not adhere to the
        // container contract
        if (! self::$container instanceof Container) {
            throw new InvalidContainerImplementation(
                'Invalid Container implementation'
            );
        }

        // Set the dispatcher to a new instance of the dispatcher implementation
        self::$dispatcher = new $dispatcherImpl($this);

        // If the dispatcher implementation specified does not adhere to the
        // dispatcher contract
        if (! self::$dispatcher instanceof Dispatcher) {
            throw new InvalidDispatcherImplementation(
                'Invalid Dispatcher implementation'
            );
        }
    }

Bootstrap core functionality.

@throws \Valkyrja\Exceptions\InvalidContainerImplementation
@throws \Valkyrja\Exceptions\InvalidDispatcherImplementation
@throws \Valkyrja\Exceptions\InvalidEventsImplementation

@return void


protected function bootstrapContainer(): void
    {
        // Set the application instance in the container
        self::$container->singleton(Application::class, $this);
        // Set the events instance in the container
        self::$container->singleton('env', self::$env);
        // Set the events instance in the container
        self::$container->singleton('config', self::$config);
        // Set the container instance in the container
        self::$container->singleton(Container::class, self::$container);
        // Set the dispatcher instance in the dispatcher
        self::$container->singleton(Dispatcher::class, self::$dispatcher);
        // Set the events instance in the container
        self::$container->singleton(Events::class, self::$events);
    }


public static function env(string $variable = null, $default = null)
    {
        // If there was no variable requested
        if (null === $variable) {
            // Return the env class
            return static::getEnv();
        }

        // If the env has this variable defined and the variable isn't null
        if (
            \defined(static::getEnv() . '::' . $variable)
            && null !== $env = \constant(static::getEnv() . '::' . $variable)
        ) {
            // Return the variable
            return $env;
        }

        // Otherwise return the default
        return $default;
    }

Get an environment variable.

@param string $variable [optional] The variable to get
@param string $default  [optional] The default value to return

@return mixed|\Valkyrja\Env\Env||config|Env


public static function setEnv(string $env = null): void
    {
        // Set the env class to use
        self::$env = $env ?? self::$env ?? Env::class;
    }

public
static
function
setEnv
(
string
$
env
=
)
:
void
{
// Set the env class to use
self
::
$
env
=
$
env
??
self
::
$
env
??
Env
::
class
;
}

Set the environment variables class.

@param string $env [optional] The env file to use

@return void


public function config(string $key = null, $default = null)
    {
        // If no key was specified
        if (null === $key) {
            // Return all the entire config
            return self::$config;
        }

        // Explode the keys on period
        $keys = explode('.', $key);
        // Set the config to return
        $config = self::$config;

        // Iterate through the keys
        foreach ($keys as $configItem) {
            // Trying to get the item from the config
            // or load the default
            $config = $config[$configItem] ?? $default;

            // If the item was not found, might as well return out from here
            // instead of continuing to iterate through the remaining keys
            if ($default === $config) {
                return $default;
            }
        }

        // do while($current !== $default);

        // Return the found config
        return $config;
    }

Get the config.

@param string $key     [optional] The key to get
@param string $default [optional] The default value if the key is not
found

@return mixed


public function abort(
        int $statusCode = StatusCode::NOT_FOUND,
        string $message = '',
        array $headers = [],
        int $code = 0,
        Response $response = null
    ): void {
        throw new HttpException($statusCode, $message, null, $headers, $code, $response);
    }

public function abort ( int $ statusCode = StatusCode :: NOT_FOUND , string $ message = '' , array $ headers = [ ] , int $ code = 0 , Response $ response = null ) : void { throw new HttpException ( $ statusCode , $ message , null , $ headers , $ code , $ response ) ; }

Abort the application due to error.

@param int      $statusCode The status code to use
@param string   $message    [optional] The Exception message to throw
@param array    $headers    [optional] The headers to send
@param int      $code       [optional] The Exception code
@param Response $response   [optional] The Response to send

@throws \Valkyrja\Http\Exceptions\HttpException

@return void


public function redirectTo(string $uri = null, int $statusCode = StatusCode::FOUND, array $headers = []): void
    {
        throw new HttpRedirectException($statusCode, $uri, null, $headers, 0);
    }

public function redirectTo ( string $ uri = null , int $ statusCode = StatusCode :: FOUND , array $ headers = [ ] ) : void { throw new HttpRedirectException ( $ statusCode , $ uri , null , $ headers , 0 ) ; }

Redirect to a given uri, and abort the application.

@param string $uri        [optional] The URI to redirect to
@param int    $statusCode [optional] The response status code
@param array  $headers    [optional] An array of response headers

@throws \Valkyrja\Http\Exceptions\HttpRedirectException

@return void

Redirect to a given uri and abort the application .


public function response(string $content = '', int $statusCode = StatusCode::OK, array $headers = []): Response
    {
        /** @var Response $response */
        $response = $this->container()->getSingleton(Response::class);

        if (\func_num_args() === 0) {
            return $response;
        }

        return $response->create($content, $statusCode, $headers);
    }

public
function
response
(
string
$
content
=
''
,
int
$
statusCode
=
StatusCode
::
OK
,
array
$
headers
=
[
]
)
:
Response
{
/** @var Response $response */
$
response
=
$
this
->
container
(
)
->
getSingleton
(
Response
::
class
)
;
if
(
\
func_num_args
(
)
===
0
)
{
return
$
response
;
}
return
$
response
->
create
(
$
content
,
$
statusCode
,
$
headers
)
;
}

Return a new response from the application.

@param string $content    [optional] The content to set
@param int    $statusCode [optional] The status code to set
@param array  $headers    [optional] The headers to set

@throws \InvalidArgumentException

@return \Valkyrja\Http\Response

Return a new response from the application .


public function redirectRoute(
        string $route,
        array $parameters = [],
        int $statusCode = StatusCode::FOUND,
        array $headers = []
    ): RedirectResponse {
        // Get the uri from the router using the route and parameters
        $uri = $this->router()->routeUrl($route, $parameters);

        return $this->redirect($uri, $statusCode, $headers);
    }

Return a new redirect response from the application for a given route.

@param string $route      The route to match
@param array  $parameters [optional] Any parameters to set for dynamic
routes
@param int    $statusCode [optional] The response status code
@param array  $headers    [optional] An array of response headers

@throws \InvalidArgumentException
@throws \Valkyrja\Http\Exceptions\InvalidStatusCodeException

@return \Valkyrja\Http\RedirectResponse

Return a new redirect response from the application for a given route .


public function view(string $template = '', array $variables = []): View
    {
        /** @var \Valkyrja\View\View $view */
        $view = $this->container()->getSingleton(View::class);

        if (\func_num_args() === 0) {
            return $view;
        }

        return $view->make($template, $variables);
    }

public
function
view
(
string
$
template
=
''
,
array
$
variables
=
[
]
)
:
View
{
/** @var \Valkyrja\View\View $view */
$
view
=
$
this
->
container
(
)
->
getSingleton
(
View
::
class
)
;
if
(
\
func_num_args
(
)
===
0
)
{
return
$
view
;
}
return
$
view
->
make
(
$
template
,
$
variables
)
;
}

Helper function to get a new view.

@param string $template  [optional] The template to use
@param array  $variables [optional] The variables to use

@return \Valkyrja\View\View


public function get($key) {
        if(!$this->exists($key)) {
            return false;
        }

        return array_get($this->items, $key);
    }

public function get ( $ key ) { if ( ! $ this -> exists ( $ key ) ) { return false ; } return array_get ( $ this -> items , $ key ) ; }

Get a configuration item.

@param $key

@return mixed


public function validateKey(string $key)
    {
        if (false === isset($this->definitions[$key])) {
            throw new \InvalidArgumentException(sprintf(
                'Descriptor "%s" not a permitted descriptor key. Did you make a typo? Permitted descriptors: "%s"',
                $key,
                implode('", "', array_keys($this->definitions))
            ));
        }
    }

Ensure that a given key is valid.

This is called when the user attempts to access a descriptor.


public function validate(string $key, DescriptorInterface $descriptor)
    {
        $this->validateKey($key);
        $definition = $this->definitions[$key];

        if (get_class($descriptor) !== $definition->getClass()) {
            throw new \InvalidArgumentException(sprintf(
                'Descriptor with key "%s" must be of class "%s", got "%s"',
                $key,
                $definition->getClass(),
                get_class($descriptor)
            ));
        }
    }

Validate the descriptor key AND ensures that the given
descriptor is of the correct type according to the schema.

This is called when a descriptor is set on the description.

Validate the descriptor key AND ensures that the given descriptor is of the correct type according to the schema .


public function getCacheInvalidationSettings() {
        if($this->cacheInvalidationSettings == null) {
            $this->cacheInvalidationSettings = '[]';
        }
        return json_decode($this->cacheInvalidationSettings, true);
    }

public function getCacheInvalidationSettings ( ) { if ( $ this -> cacheInvalidationSettings == null ) { $ this -> cacheInvalidationSettings = '[]' ; } return json_decode ( $ this -> cacheInvalidationSettings , true ) ; }

Returns the cache invalidation settings.

@return array

Returns the cache invalidation settings .


public function setCacheInvalidationSettings($settings) {
        $this->cacheInvalidationSettings = is_string($settings) ? $settings : json_encode($settings, JSON_PRETTY_PRINT);
        return $this;
    }

public function setCacheInvalidationSettings ( $ settings ) { $ this -> cacheInvalidationSettings = is_string ( $ settings ) ? $ settings : json_encode ( $ settings , JSON_PRETTY_PRINT ) ; return $ this ; }

Sets the cache invalidation settings.

@param  array|string $settings
@return $this


protected function init(array $user_options = array(), $logname = null)
    {
        $app_config = CarteBlanche::getConfig('log', array(), true);
        $app_config['directory'] = CarteBlanche::getFullPath('log_dir');
        $user_config = CarteBlanche::getConfig('log', array());
        if (!empty($user_config)) {
            $config = array_merge($app_config, $user_config, $user_options);
        } else {
            $config = array_merge($app_config, $user_options);
        }
        parent::init($config, $logname);
    }

protected function init ( array $ user_options = array ( ) , $ logname = null ) { $ app_config = CarteBlanche :: getConfig ( 'log' , array ( ) , true ) ; $ app_config [ 'directory' ] = CarteBlanche :: getFullPath ( 'log_dir' ) ; $ user_config = CarteBlanche :: getConfig ( 'log' , array ( ) ) ; if ( ! empty ( $ user_config ) ) { $ config = array_merge ( $ app_config , $ user_config , $ user_options ) ; } else { $ config = array_merge ( $ app_config , $ user_options ) ; } parent :: init ( $ config , $ logname ) ; }

Load the configuration infos

@param array $user_options
@param string $logname

@return void


protected function getFilePath($level = 100)
    {
        $mode = CarteBlanche::getKernel()->getMode();
        return DirectoryHelper::slashDirname($this->directory)
            .$this->getFileName($level)
            .($mode!='prod' ? '_'.$mode : '' )
            .'.'.trim($this->logfile_extension, '.');
    }

protected function getFilePath ( $ level = 100 ) { $ mode = CarteBlanche :: getKernel ( ) -> getMode ( ) ; return DirectoryHelper :: slashDirname ( $ this -> directory ) . $ this -> getFileName ( $ level ) . ( $ mode != 'prod' ? '_' . $ mode : '' ) . '.' . trim ( $ this -> logfile_extension , '.' ) ; }

Get the log file path

@param int $level The level of the current log info (default is 100)

@return string The absolute path of the logfile to write in


public function verify($password, $hash)
    {
        $verify = password_verify($password, $hash);

        if (true === $verify && $this->isRehashIfNeeded() && $this->needsRehash($hash)) {
            $newHash = $this->create($password);
            $verify = [
                'verify' => true,
                'hash' => $newHash,
            ];
        }

        return $verify;
    }

public function verify ( $ password , $ hash ) { $ verify = password_verify ( $ password , $ hash ) ; if ( true === $ verify && $ this -> isRehashIfNeeded ( ) && $ this -> needsRehash ( $ hash ) ) { $ newHash = $ this -> create ( $ password ) ; $ verify = [ 'verify' => true , 'hash' => $ newHash , ] ; } return $ verify ; }

Verify if a password is correct against a hash value.

@param string $password
@param string $hash
@return bool|array

Verify if a password is correct against a hash value .


public function setExists($exists)
    {
        if ($exists instanceof Zend_Config) {
            $exists = $exists->toArray();
        }

        if (is_array($exists)) {
            if (isset($exists['exists'])) {
                $exists = (boolean) $exists['exists'];
            }
        }

        $this->_exists = (boolean) $exists;
        return $this;
    }

public function setExists ( $ exists ) { if ( $ exists instanceof Zend_Config ) { $ exists = $ exists -> toArray ( ) ; } if ( is_array ( $ exists ) ) { if ( isset ( $ exists [ 'exists' ] ) ) { $ exists = ( boolean ) $ exists [ 'exists' ] ; } } $ this -> _exists = ( boolean ) $ exists ; return $ this ; }

Sets if the path has to exist
TRUE when the path must exist
FALSE when not existing paths can be given

@param boolean|Zend_Config $exists Path must exist
@return Zend_Filter_RealPath


protected function renderProgress()
    {
        if (empty($this->bars)) {
            $config = ['percent' => $this->percent, 'animated' => $this->animated, 'striped' => $this->striped];
            return $this->renderBar($config, $this->label, $this->barOptions);
        }
        $bars = [];
        foreach ($this->bars as $bar) {
            $label = ArrayHelper::getValue($bar, 'label', '');
            if (!isset($bar['percent'])) {
                throw new InvalidConfigException("The 'percent' option is required.");
            }
            $options = ArrayHelper::getValue($bar, 'options', []);
            $bars[] = $this->renderBar($bar, $label, $options);
        }

        return implode("\n", $bars);
    }

protected
function
renderProgress
(
)
{
if
(
empty
(
$
this
->
bars
)
)
{
$
config
=
[
'percent'
=>
$
this
->
percent
,
'animated'
=>
$
this
->
animated
,
'striped'
=>
$
this
->
striped
]
;
return
$
this
->
renderBar
(
$
config
,
$
this
->
label
,
$
this
->
barOptions
)
;
}
$
bars
=
[
]
;
foreach
(
$
this
->
bars
as
$
bar
)
{
$
label
=
ArrayHelper
::
getValue
(
$
bar
,
'label'
,
''
)
;
if
(
!
isset
(
$
bar
[
'percent'
]
)
)
{
throw
new
InvalidConfigException
(
"The 'percent' option is required."
)
;
}
$
options
=
ArrayHelper
::
getValue
(
$
bar
,
'options'
,
[
]
)
;
$
bars
[
]
=
$
this
->
renderBar
(
$
bar
,
$
label
,
$
options
)
;
}
return
implode
(
"\n"
,
$
bars
)
;
}

Renders the progress.
@return string the rendering result.
@throws InvalidConfigException if the "percent" option is not set in a stacked progress bar.


protected function renderBar($config = [], $label, $options = []) {
        $percent = ArrayHelper::getValue($config, 'percent', 0);
        $animated = ArrayHelper::getValue($config, 'animated', false);
        $striped = ArrayHelper::getValue($config, 'striped', false) || $animated;
        $percentFixed = number_format($percent, 2, '.', '');
        $defaultOptions = [
            'role' => 'progressbar',
            'aria-valuenow' => $percent,
            'aria-valuemin' => 0,
            'aria-valuemax' => 100,
            'style' => "width:{$percentFixed}%",
        ];
        $options = array_merge($defaultOptions, $options);
        Html::addCssClass($options, ['widget' => 'progress-bar']);
        if ($animated) {
            Html::addCssClass($options, ['animated' => 'progress-bar-animated']);
        }
        if ($striped) {
            Html::addCssClass($options, ['striped' => 'progress-bar-striped']);
        }

        $out = $this->htmlHlp->beginTag('div', $options);
        $out .= $label;
        $out .= $this->htmlHlp->tag('span', \Reaction::t('rct', '{percent}% Complete', ['percent' => $percent]), [
            'class' => 'sr-only'
        ]);
        $out .= Html::endTag('div');

        return $out;
    }

protected
function
renderBar
(
$
config
=
[
]
,
$
label
,
$
options
=
[
]
)
{
$
percent
=
ArrayHelper
::
getValue
(
$
config
,
'percent'
,
0
)
;
$
animated
=
ArrayHelper
::
getValue
(
$
config
,
'animated'
,
false
)
;
$
striped
=
ArrayHelper
::
getValue
(
$
config
,
'striped'
,
false
)
||
$
animated
;
$
percentFixed
=
number_format
(
$
percent
,
2
,
'.'
,
''
)
;
$
defaultOptions
=
[
'role'
=>
'progressbar'
,
'aria-valuenow'
=>
$
percent
,
'aria-valuemin'
=>
0
,
'aria-valuemax'
=>
100
,
'style'
=>
"width:{$percentFixed}%"
,
]
;
$
options
=
array_merge
(
$
defaultOptions
,
$
options
)
;
Html
::
addCssClass
(
$
options
,
[
'widget'
=>
'progress-bar'
]
)
;
if
(
$
animated
)
{
Html
::
addCssClass
(
$
options
,
[
'animated'
=>
'progress-bar-animated'
]
)
;
}
if
(
$
striped
)
{
Html
::
addCssClass
(
$
options
,
[
'striped'
=>
'progress-bar-striped'
]
)
;
}
$
out
=
$
this
->
htmlHlp
->
beginTag
(
'div'
,
$
options
)
;
$
out
.=
$
label
;
$
out
.=
$
this
->
htmlHlp
->
tag
(
'span'
,
\
Reaction
::
t
(
'rct'
,
'{percent}% Complete'
,
[
'percent'
=>
$
percent
]
)
,
[
'class'
=>
'sr-only'
]
)
;
$
out
.=
Html
::
endTag
(
'div'
)
;
return
$
out
;
}

Generates a bar
@param array $config the bar config (percentage, striped, animated)
@param string $label, optional, the label to display at the bar
@param array $options the HTML attributes of the bar
@return string the rendering result.


public function processSoap(){
        $this->wsdl = new jWSDL($this->request->params['module'], $this->request->params['action']);

        $this->soapServer = $this->getSoapServer($this->wsdl);
        $this->soapServer->setclass('jSoapHandler', $this);
        $this->soapServer->handle($this->request->soapMsg);
    }

public function processSoap ( ) { $ this -> wsdl = new jWSDL ( $ this -> request -> params [ 'module' ] , $ this -> request -> params [ 'action' ] ) ; $ this -> soapServer = $ this -> getSoapServer ( $ this -> wsdl ) ; $ this -> soapServer -> setclass ( 'jSoapHandler' , $ this ) ; $ this -> soapServer -> handle ( $ this -> request -> soapMsg ) ; }

Intercept the soapServer method call in order to handle the call thrue the process method
Return php variables, the soap server will transform it in a soap response

Intercept the soapServer method call in order to handle the call thrue the process method Return php variables the soap server will transform it in a soap response


public function getSoapServer($wsdl = null){

        if(is_null($this->soapServer)){
            if(is_null($wsdl)){
                $this->soapServer = new SoapServer(null, array('soap_version' => SOAP_1_1, 'encoding' => jApp::config()->charset, 'uri' => $_SERVER['PHP_SELF']));
            }else{
                $this->soapServer = new SoapServer($wsdl->getWSDLFilePath(), array('soap_version' => SOAP_1_1, 'encoding' => jApp::config()->charset));
            }
        }
        return $this->soapServer;
    }

public function getSoapServer ( $ wsdl = null ) { if ( is_null ( $ this -> soapServer ) ) { if ( is_null ( $ wsdl ) ) { $ this -> soapServer = new SoapServer ( null , array ( 'soap_version' => SOAP_1_1 , 'encoding' => jApp :: config ( ) -> charset , 'uri' => $ _SERVER [ 'PHP_SELF' ] ) ) ; } else { $ this -> soapServer = new SoapServer ( $ wsdl -> getWSDLFilePath ( ) , array ( 'soap_version' => SOAP_1_1 , 'encoding' => jApp :: config ( ) -> charset ) ) ; } } return $ this -> soapServer ; }

Init and return the soap server
Use wsdl mode or not depending of the wsdl object param
@param jWsdl $wsdl
@return SoapServer


public function onFlush(OnFlushEventArgs $eventArgs)
    {
        $em = $eventArgs->getEntityManager();
        $uow = $em->getUnitOfWork();

        foreach ($uow->getScheduledEntityInsertions() as $entity) {
            $this->invalidateEntity($entity);
        }

        foreach ($uow->getScheduledEntityUpdates() as $entity) {
            $this->invalidateEntity($entity);
        }

        foreach ($uow->getScheduledEntityDeletions() as $entity) {
            $this->invalidateEntity($entity);
        }

        /** @var \Doctrine\Common\Collections\ArrayCollection $col */
        foreach ($uow->getScheduledCollectionUpdates() as $col) {
            foreach ($col as $entity) {
                $this->invalidateEntity($entity);
            }
        }

        foreach ($uow->getScheduledCollectionDeletions() as $col) {
            foreach ($col as $entity) {
                $this->invalidateEntity($entity);
            }
        }
    }

On flush event handler.

@param OnFlushEventArgs $eventArgs


public function postFlush()
    {
        $this->eventDispatcher->dispatch(
            HttpCacheEvents::INVALIDATE_TAG,
            new HttpCacheEvent($this->tagsToInvalidate)
        );
        $this->reset();
    }

public function postFlush ( ) { $ this -> eventDispatcher -> dispatch ( HttpCacheEvents :: INVALIDATE_TAG , new HttpCacheEvent ( $ this -> tagsToInvalidate ) ) ; $ this -> reset ( ) ; }


private function invalidateEntity($entity)
    {
        if ($entity instanceof TaggedEntityInterface) {
            $this->addTagToInvalidate($entity::getEntityTagPrefix());
            if (null !== $entity->getId()) {
                $this->addTagToInvalidate($entity->getEntityTag());
            }
        } elseif ($entity instanceof TranslationInterface) {
            $translatable = $entity->getTranslatable();
            $this->invalidateEntity($translatable);
        }
    }

private function invalidateEntity ( $ entity ) { if ( $ entity instanceof TaggedEntityInterface ) { $ this -> addTagToInvalidate ( $ entity :: getEntityTagPrefix ( ) ) ; if ( null !== $ entity -> getId ( ) ) { $ this -> addTagToInvalidate ( $ entity -> getEntityTag ( ) ) ; } } elseif ( $ entity instanceof TranslationInterface ) { $ translatable = $ entity -> getTranslatable ( ) ; $ this -> invalidateEntity ( $ translatable ) ; } }

Invalidates the entity http cache.

@param object $entity


private function addTagToInvalidate($tag)
    {
        if (0 < strlen($tag) && !in_array($tag, $this->tagsToInvalidate)) {
            $this->tagsToInvalidate[] = $tag;
        }
    }

private function addTagToInvalidate ( $ tag ) { if ( 0 < strlen ( $ tag ) && ! in_array ( $ tag , $ this -> tagsToInvalidate ) ) { $ this -> tagsToInvalidate [ ] = $ tag ; } }

Adds tag to invalidate.

@param string $tag


public static function choiceSexe()
	{
		return array('Sexe.choice.' . self::SEXE_MISS => self::SEXE_MISS, 'Sexe.choice.' . self::SEXE_MRS => self::SEXE_MRS,
			'Sexe.choice.' . self::SEXE_MR => self::SEXE_MR);
	}

public static function choiceSexe ( ) { return array ( 'Sexe.choice.' . self :: SEXE_MISS => self :: SEXE_MISS , 'Sexe.choice.' . self :: SEXE_MRS => self :: SEXE_MRS , 'Sexe.choice.' . self :: SEXE_MR => self :: SEXE_MR ) ; }

Choice Form sexe

@return multitype:string


public function setCallback($callback, $options = null)
    {
        if (!is_callable($callback)) {

            throw new Zend_Filter_Exception('Callback can not be accessed');
        }

        $this->_callback = $callback;
        $this->setOptions($options);
        return $this;
    }

public
function
setCallback
(
$
callback
,
$
options
=
)
{
if
(
!
is_callable
(
$
callback
)
)
{
throw
new
Zend_Filter_Exception
(
'Callback can not be accessed'
)
;
}
$
this
->
_callback
=
$
callback
;
$
this
->
setOptions
(
$
options
)
;
return
$
this
;
}

Sets a new callback for this filter

@param unknown_type $callback
@return unknown


public function filter($value)
    {
        $options = array();

        if ($this->_options !== null) {
            if (!is_array($this->_options)) {
                $options = array($this->_options);
            } else {
                $options = $this->_options;
            }
        }

        array_unshift($options, $value);

        return call_user_func_array($this->_callback, $options);
    }

public function filter ( $ value ) { $ options = array ( ) ; if ( $ this -> _options !== null ) { if ( ! is_array ( $ this -> _options ) ) { $ options = array ( $ this -> _options ) ; } else { $ options = $ this -> _options ; } } array_unshift ( $ options , $ value ) ; return call_user_func_array ( $ this -> _callback , $ options ) ; }

Calls the filter per callback

@param mixed $value Options for the set callback
@return mixed       Result from the filter which was callbacked


public function getFillingPercentage()
    {
        $mem = wincache_ucache_meminfo();
        $memSize = $mem['memory_total'];
        $memUsed = $memSize - $mem['memory_free'];
        if ($memSize == 0) {
            Zend_Cache::throwException('can\'t get WinCache memory size');
        }
        if ($memUsed > $memSize) {
            return 100;
        }
        return ((int) (100. * ($memUsed / $memSize)));
    }

public
function
getFillingPercentage
(
)
{
$
mem
=
wincache_ucache_meminfo
(
)
;
$
memSize
=
$
mem
[
'memory_total'
]
;
$
memUsed
=
$
memSize
$
mem
[
'memory_free'
]
;
if
(
$
memSize
==
0
)
{
Zend_Cache
::
throwException
(
'can\'t get WinCache memory size'
)
;
}
if
(
$
memUsed
>
$
memSize
)
{
return
100
;
}
return
(
(
int
)
(
100.
*
(
$
memUsed
/
$
memSize
)
)
)
;
}

Return the filling percentage of the backend storage

@throws Zend_Cache_Exception
@return int integer between 0 and 100


public function getAllSeobility($force = false)
    {
        $this->_seo = (array)($force ? [] : $this->_seo) + Seo::findAll($this->owner);
        return ArrayHelper::toArray($this->_seo, ['inblank\seobility\models\Seo' => ['title', 'keywords', 'description']]);
    }

public function getAllSeobility ( $ force = false ) { $ this -> _seo = ( array ) ( $ force ? [ ] : $ this -> _seo ) + Seo :: findAll ( $ this -> owner ) ; return ArrayHelper :: toArray ( $ this -> _seo , [ 'inblank\seobility\models\Seo' => [ 'title' , 'keywords' , 'description' ] ] ) ; }

Get all SEO data for model
@param bool $force if `true`, force get with overwrite current SEO data
@return array


public function setSeobility($values, $condition = 0)
    {
        $condition = (int)$condition;
        if (!array_key_exists($condition, $this->_seo)) {
            $this->_seo[$condition] = Seo::find($this->owner, $condition);
        }
        $this->_seo[$condition]->setAttributes($values);
    }

public function setSeobility ( $ values , $ condition = 0 ) { $ condition = ( int ) $ condition ; if ( ! array_key_exists ( $ condition , $ this -> _seo ) ) { $ this -> _seo [ $ condition ] = Seo :: find ( $ this -> owner , $ condition ) ; } $ this -> _seo [ $ condition ] -> setAttributes ( $ values ) ; }

Set SEO data
@param string[] $values setting values
@param int $condition SEO data condition for select. Condition =0 for default SEO data


public function getSeobility($condition = 0, $defaultIfNotFound = true, $defaultCondition = 0)
    {
        $condition = (int)$condition;
        if (!array_key_exists($condition, $this->_seo)) {
            $this->_seo[$condition] = Seo::find($this->owner, $condition);
            if ($this->_seo[$condition]->getIsNewRecord() && $defaultIfNotFound) {
                $this->getSeobility((int)$defaultCondition, false);
            }
        }
        return $this->_seo[$condition]->getAttributes(['title', 'keywords', 'description']);
    }

public function getSeobility ( $ condition = 0 , $ defaultIfNotFound = true , $ defaultCondition = 0 ) { $ condition = ( int ) $ condition ; if ( ! array_key_exists ( $ condition , $ this -> _seo ) ) { $ this -> _seo [ $ condition ] = Seo :: find ( $ this -> owner , $ condition ) ; if ( $ this -> _seo [ $ condition ] -> getIsNewRecord ( ) && $ defaultIfNotFound ) { $ this -> getSeobility ( ( int ) $ defaultCondition , false ) ; } } return $ this -> _seo [ $ condition ] -> getAttributes ( [ 'title' , 'keywords' , 'description' ] ) ; }

Get SEO data
@param int $condition SEO data condition for get. Default SEO data have condition=0
@param bool $defaultIfNotFound flag that get default SEO data if not found by condition
@param int $defaultCondition default SEO data condition for get.
If can't get SEO data with this condition will be return empty SEO data
@return \string[]


function convert(): bool
    {
        if (!is_string($this->value)) {
            $this->result = $this->value;
        }
        else {
            switch (strtolower($this->value)) {
                case '1':
                case 'true':
                case 'on':
                case 'yes':
                case 'y':
                    $this->result = true;
                default:
                    $this->result = false;
            }
        }

        return $this->result;
    }

function convert ( ) : bool { if ( ! is_string ( $ this -> value ) ) { $ this -> result = $ this -> value ; } else { switch ( strtolower ( $ this -> value ) ) { case '1' : case 'true' : case 'on' : case 'yes' : case 'y' : $ this -> result = true ; default : $ this -> result = false ; } } return $ this -> result ; }

Converts a value into boolean.

Strings like '1', 'true', 'on', 'yes' or 'y' will converted into boolean true

@return boolean


public function getOrdinateByAbscissa($x)
    {
        $o = $this->getPointO();
        return (sqrt(pow($this->getRadius(), 2) - pow(($x - $o->getAbscissa()), 2)) + $o->getOrdinate());
    }

public function getOrdinateByAbscissa ( $ x ) { $ o = $ this -> getPointO ( ) ; return ( sqrt ( pow ( $ this -> getRadius ( ) , 2 ) - pow ( ( $ x - $ o -> getAbscissa ( ) ) , 2 ) ) + $ o -> getOrdinate ( ) ) ; }

Get the ordinate of a point of the circle by its abscissa

y = sqrt( r^2 - (x - Ox)^2 ) + Oy

@param   float   $x
@return  float


public function getAbscissaByOrdinate($y)
    {
        $o = $this->getPointO();
        return (sqrt(pow($this->getRadius(), 2) - pow(($y - $o->getOrdinate()), 2)) + $o->getAbscissa());
    }

public function getAbscissaByOrdinate ( $ y ) { $ o = $ this -> getPointO ( ) ; return ( sqrt ( pow ( $ this -> getRadius ( ) , 2 ) - pow ( ( $ y - $ o -> getOrdinate ( ) ) , 2 ) ) + $ o -> getAbscissa ( ) ) ; }

Get the abscissa of a point of the circle by its ordinate

x = sqrt( r^2 - (y - Oy)^2 ) + Ox

@param   float   $y
@return  float


public function attachment($name, $content, $content_type)
    {
        $this->data['Attachments'][$this->attachment_count]['Name']         = $name;
        $this->data['Attachments'][$this->attachment_count]['ContentType']  = $content_type;

        // Check if our content is already base64 encoded or not
        if(! base64_decode($content, true))
            $this->data['Attachments'][$this->attachment_count]['Content']  = base64_encode($content);
        else
            $this->data['Attachments'][$this->attachment_count]['Content']  = $content;

        // Up our attachment counter
        $this->attachment_count++;

        return $this;
    }

Add Attachment Method

@method mixed attachment($name, $content, $content_type) Add Attachment Method
@access public
@param  $name
@param  $content
@param  $content_type
@return $this


function encode($boundary=null)
    {
        $encoded =& $this->_encoded;

        if (count($this->_subparts)) {
            $boundary = $boundary ? $boundary : '=_' . md5(rand() . microtime());
            $eol = $this->_eol;

            $this->_headers['Content-Type'] .= ";$eol boundary=\"$boundary\"";

            $encoded['body'] = '';

            for ($i = 0; $i < count($this->_subparts); $i++) {
                $encoded['body'] .= '--' . $boundary . $eol;
                $tmp = $this->_subparts[$i]->encode();
                if ($this->_isError($tmp)) {
                    return $tmp;
                }
                foreach ($tmp['headers'] as $key => $value) {
                    $encoded['body'] .= $key . ': ' . $value . $eol;
                }
                $encoded['body'] .= $eol . $tmp['body'] . $eol;
            }

            $encoded['body'] .= '--' . $boundary . '--' . $eol;

        } else if ($this->_body) {
            $encoded['body'] = $this->_getEncodedData($this->_body, $this->_encoding);
        } else if ($this->_body_file) {
            // Temporarily reset magic_quotes_runtime for file reads and writes
            if ($magic_quote_setting = get_magic_quotes_runtime()) {
                @ini_set('magic_quotes_runtime', 0);
            }
            $body = $this->_getEncodedDataFromFile($this->_body_file, $this->_encoding);
            if ($magic_quote_setting) {
                @ini_set('magic_quotes_runtime', $magic_quote_setting);
            }

            if ($this->_isError($body)) {
                return $body;
            }
            $encoded['body'] = $body;
        } else {
            $encoded['body'] = '';
        }

        // Add headers to $encoded
        $encoded['headers'] =& $this->_headers;

        return $encoded;
    }

Encodes and returns the email. Also stores
it in the encoded member variable

@param string $boundary Pre-defined boundary string

@return An associative array containing two elements,
body and headers. The headers element is itself
an indexed array. On error returns PEAR error object.
@access public

Encodes and returns the email . Also stores it in the encoded member variable


function encodeToFile($filename, $boundary=null, $skip_head=false)
    {
        if (file_exists($filename) && !is_writable($filename)) {
            $err = $this->_raiseError('File is not writeable: ' . $filename);
            return $err;
        }

        if (!($fh = fopen($filename, 'ab'))) {
            $err = $this->_raiseError('Unable to open file: ' . $filename);
            return $err;
        }

        // Temporarily reset magic_quotes_runtime for file reads and writes
        if ($magic_quote_setting = get_magic_quotes_runtime()) {
            @ini_set('magic_quotes_runtime', 0);
        }

        $res = $this->_encodePartToFile($fh, $boundary, $skip_head);

        fclose($fh);

        if ($magic_quote_setting) {
            @ini_set('magic_quotes_runtime', $magic_quote_setting);
        }

        return $this->_isError($res) ? $res : $this->_headers;
    }

Encodes and saves the email into file. File must exist.
Data will be appended to the file.

@param string  $filename  Output file location
@param string  $boundary  Pre-defined boundary string
@param boolean $skip_head True if you don't want to save headers

@return array An associative array containing message headers
or PEAR error object
@access public
@since 1.6.0

Encodes and saves the email into file . File must exist . Data will be appended to the file .


function _encodePartToFile($fh, $boundary=null, $skip_head=false)
    {
        $eol = $this->_eol;

        if (count($this->_subparts)) {
            $boundary = $boundary ? $boundary : '=_' . md5(rand() . microtime());
            $this->_headers['Content-Type'] .= ";$eol boundary=\"$boundary\"";
        }

        if (!$skip_head) {
            foreach ($this->_headers as $key => $value) {
                fwrite($fh, $key . ': ' . $value . $eol);
            }
            $f_eol = $eol;
        } else {
            $f_eol = '';
        }

        if (count($this->_subparts)) {
            for ($i = 0; $i < count($this->_subparts); $i++) {
                fwrite($fh, $f_eol . '--' . $boundary . $eol);
                $res = $this->_subparts[$i]->_encodePartToFile($fh);
                if ($this->_isError($res)) {
                    return $res;
                }
                $f_eol = $eol;
            }

            fwrite($fh, $eol . '--' . $boundary . '--' . $eol);

        } else if ($this->_body) {
            fwrite($fh, $f_eol . $this->_getEncodedData($this->_body, $this->_encoding));
        } else if ($this->_body_file) {
            fwrite($fh, $f_eol);
            $res = $this->_getEncodedDataFromFile(
                $this->_body_file, $this->_encoding, $fh
            );
            if ($this->_isError($res)) {
                return $res;
            }
        }

        return true;
    }

function
_encodePartToFile
(
$
fh
,
$
boundary
=
,
$
skip_head
=
false
)
{
$
eol
=
$
this
->
_eol
;
if
(
count
(
$
this
->
_subparts
)
)
{
$
boundary
=
$
boundary
$
boundary
:
'=_'
.
md5
(
rand
(
)
.
microtime
(
)
)
;
$
this
->
_headers
[
'Content-Type'
]
.=
";$eol boundary=\"$boundary\""
;
}
if
(
!
$
skip_head
)
{
foreach
(
$
this
->
_headers
as
$
key
=>
$
value
)
{
fwrite
(
$
fh
,
$
key
.
': '
.
$
value
.
$
eol
)
;
}
$
f_eol
=
$
eol
;
}
else
{
$
f_eol
=
''
;
}
if
(
count
(
$
this
->
_subparts
)
)
{
for
(
$
i
=
0
;
$
i
<
count
(
$
this
->
_subparts
)
;
$
i
++
)
{
fwrite
(
$
fh
,
$
f_eol
.
'--'
.
$
boundary
.
$
eol
)
;
$
res
=
$
this
->
_subparts
[
$
i
]
->
_encodePartToFile
(
$
fh
)
;
if
(
$
this
->
_isError
(
$
res
)
)
{
return
$
res
;
}
$
f_eol
=
$
eol
;
}
fwrite
(
$
fh
,
$
eol
.
'--'
.
$
boundary
.
'--'
.
$
eol
)
;
}
else
if
(
$
this
->
_body
)
{
fwrite
(
$
fh
,
$
f_eol
.
$
this
->
_getEncodedData
(
$
this
->
_body
,
$
this
->
_encoding
)
)
;
}
else
if
(
$
this
->
_body_file
)
{
fwrite
(
$
fh
,
$
f_eol
)
;
$
res
=
$
this
->
_getEncodedDataFromFile
(
$
this
->
_body_file
,
$
this
->
_encoding
,
$
fh
)
;
if
(
$
this
->
_isError
(
$
res
)
)
{
return
$
res
;
}
}
return
true
;
}

Encodes given email part into file

@param string  $fh        Output file handle
@param string  $boundary  Pre-defined boundary string
@param boolean $skip_head True if you don't want to save headers

@return array True on sucess or PEAR error object
@access private


function &addSubpart($body, $params)
    {
        $this->_subparts[] = $part = new Mail_mimePart($body, $params);
        return $part;
    }

function & addSubpart ( $ body , $ params ) { $ this -> _subparts [ ] = $ part = new Mail_mimePart ( $ body , $ params ) ; return $ part ; }

Adds a subpart to current mime part and returns
a reference to it

@param string $body   The body of the subpart, if any.
@param array  $params The parameters for the subpart, same
as the $params argument for constructor.

@return Mail_mimePart A reference to the part you just added. In PHP4, it is
crucial if using multipart/* in your subparts that
you use =& in your script when calling this function,
otherwise you will not be able to add further subparts.
@access public


function _quotedPrintableEncode($input , $line_max = 76)
    {
        $eol = $this->_eol;
        /*
        // imap_8bit() is extremely fast, but doesn't handle properly some characters
        if (function_exists('imap_8bit') && $line_max == 76) {
            $input = preg_replace('/\r?\n/', "\r\n", $input);
            $input = imap_8bit($input);
            if ($eol != "\r\n") {
                $input = str_replace("\r\n", $eol, $input);
            }
            return $input;
        }
        */
        $lines  = preg_split("/\r?\n/", $input);
        $escape = '=';
        $output = '';

        while (list($idx, $line) = each($lines)) {
            $newline = '';
            $i = 0;

            while (isset($line[$i])) {
                $char = $line[$i];
                $dec  = ord($char);
                $i++;

                if (($dec == 32) && (!isset($line[$i]))) {
                    // convert space at eol only
                    $char = '=20';
                } elseif ($dec == 9 && isset($line[$i])) {
                    ; // Do nothing if a TAB is not on eol
                } elseif (($dec == 61) || ($dec < 32) || ($dec > 126)) {
                    $char = $escape . sprintf('%02X', $dec);
                } elseif (($dec == 46) && (($newline == '')
                    || ((strlen($newline) + strlen("=2E")) >= $line_max))
                ) {
                    // Bug #9722: convert full-stop at bol,
                    // some Windows servers need this, won't break anything (cipri)
                    // Bug #11731: full-stop at bol also needs to be encoded
                    // if this line would push us over the line_max limit.
                    $char = '=2E';
                }

                // Note, when changing this line, also change the ($dec == 46)
                // check line, as it mimics this line due to Bug #11731
                // EOL is not counted
                if ((strlen($newline) + strlen($char)) >= $line_max) {
                    // soft line break; " =\r\n" is okay
                    $output  .= $newline . $escape . $eol;
                    $newline  = '';
                }
                $newline .= $char;
            } // end of for
            $output .= $newline . $eol;
            unset($lines[$idx]);
        }
        // Don't want last crlf
        $output = substr($output, 0, -1 * strlen($eol));
        return $output;
    }

Encodes data to quoted-printable standard.

@param string $input    The data to encode
@param int    $line_max Optional max line length. Should
not be more than 76 chars

@return string Encoded data

@access private

Encodes data to quoted - printable standard .


function _buildHeaderParam($name, $value, $charset=null, $language=null,
        $encoding=null, $maxLength=75
    ) {
        // RFC 2045:
        // value needs encoding if contains non-ASCII chars or is longer than 78 chars
        if (!preg_match('#[^\x20-\x7E]#', $value)) {
            $token_regexp = '#([^\x21\x23-\x27\x2A\x2B\x2D'
                . '\x2E\x30-\x39\x41-\x5A\x5E-\x7E])#';
            if (!preg_match($token_regexp, $value)) {
                // token
                if (strlen($name) + strlen($value) + 3 <= $maxLength) {
                    return " {$name}={$value}";
                }
            } else {
                // quoted-string
                $quoted = addcslashes($value, '\\"');
                if (strlen($name) + strlen($quoted) + 5 <= $maxLength) {
                    return " {$name}=\"{$quoted}\"";
                }
            }
        }

        // RFC2047: use quoted-printable/base64 encoding
        if ($encoding == 'quoted-printable' || $encoding == 'base64') {
            return $this->_buildRFC2047Param($name, $value, $charset, $encoding);
        }

        // RFC2231:
        $encValue = preg_replace_callback(
            '/([^\x21\x23\x24\x26\x2B\x2D\x2E\x30-\x39\x41-\x5A\x5E-\x7E])/',
            array($this, '_encodeReplaceCallback'), $value
        );
        $value = "$charset'$language'$encValue";

        $header = " {$name}*={$value}";
        if (strlen($header) <= $maxLength) {
            return $header;
        }

        $preLength = strlen(" {$name}*0*=");
        $maxLength = max(16, $maxLength - $preLength - 3);
        $maxLengthReg = "|(.{0,$maxLength}[^\%][^\%])|";

        $headers = array();
        $headCount = 0;
        while ($value) {
            $matches = array();
            $found = preg_match($maxLengthReg, $value, $matches);
            if ($found) {
                $headers[] = " {$name}*{$headCount}*={$matches[0]}";
                $value = substr($value, strlen($matches[0]));
            } else {
                $headers[] = " {$name}*{$headCount}*={$value}";
                $value = '';
            }
            $headCount++;
        }

        $headers = implode(';' . $this->_eol, $headers);
        return $headers;
    }

Encodes the parameter of a header.

@param string $name      The name of the header-parameter
@param string $value     The value of the paramter
@param string $charset   The characterset of $value
@param string $language  The language used in $value
@param string $encoding  Parameter encoding. If not set, parameter value
is encoded according to RFC2231
@param int    $maxLength The maximum length of a line. Defauls to 75

@return string

@access private


function _buildRFC2047Param($name, $value, $charset,
        $encoding='quoted-printable', $maxLength=76
    ) {
        // WARNING: RFC 2047 says: "An 'encoded-word' MUST NOT be used in
        // parameter of a MIME Content-Type or Content-Disposition field",
        // but... it's supported by many clients/servers
        $quoted = '';

        if ($encoding == 'base64') {
            $value = base64_encode($value);
            $prefix = '=?' . $charset . '?B?';
            $suffix = '?=';

            // 2 x SPACE, 2 x '"', '=', ';'
            $add_len = strlen($prefix . $suffix) + strlen($name) + 6;
            $len = $add_len + strlen($value);

            while ($len > $maxLength) {
                // We can cut base64-encoded string every 4 characters
                $real_len = floor(($maxLength - $add_len) / 4) * 4;
                $_quote = substr($value, 0, $real_len);
                $value = substr($value, $real_len);

                $quoted .= $prefix . $_quote . $suffix . $this->_eol . ' ';
                $add_len = strlen($prefix . $suffix) + 4; // 2 x SPACE, '"', ';'
                $len = strlen($value) + $add_len;
            }
            $quoted .= $prefix . $value . $suffix;

        } else {
            // quoted-printable
            $value = $this->encodeQP($value);
            $prefix = '=?' . $charset . '?Q?';
            $suffix = '?=';

            // 2 x SPACE, 2 x '"', '=', ';'
            $add_len = strlen($prefix . $suffix) + strlen($name) + 6;
            $len = $add_len + strlen($value);

            while ($len > $maxLength) {
                $length = $maxLength - $add_len;
                // don't break any encoded letters
                if (preg_match("/^(.{0,$length}[^\=][^\=])/", $value, $matches)) {
                    $_quote = $matches[1];
                }

                $quoted .= $prefix . $_quote . $suffix . $this->_eol . ' ';
                $value = substr($value, strlen($_quote));
                $add_len = strlen($prefix . $suffix) + 4; // 2 x SPACE, '"', ';'
                $len = strlen($value) + $add_len;
            }

            $quoted .= $prefix . $value . $suffix;
        }

        return " {$name}=\"{$quoted}\"";
    }

Encodes header parameter as per RFC2047 if needed

@param string $name      The parameter name
@param string $value     The parameter value
@param string $charset   The parameter charset
@param string $encoding  Encoding type (quoted-printable or base64)
@param int    $maxLength Encoded parameter max length. Default: 76

@return string Parameter line
@access private


function _explodeQuotedString($delimiter, $string)
    {
        $result = array();
        $strlen = strlen($string);

        for ($q=$p=$i=0; $i < $strlen; $i++) {
            if ($string[$i] == "\""
                && (empty($string[$i-1]) || $string[$i-1] != "\\")
            ) {
                $q = $q ? false : true;
            } else if (!$q && preg_match("/$delimiter/", $string[$i])) {
                $result[] = substr($string, $p, $i - $p);
                $p = $i + 1;
            }
        }

        $result[] = substr($string, $p);
        return $result;
    }

function _explodeQuotedString ( $ delimiter , $ string ) { $ result = array ( ) ; $ strlen = strlen ( $ string ) ; for ( $ q = $ p = $ i = 0 ; $ i < $ strlen ; $ i ++ ) { if ( $ string [ $ i ] == "\"" && ( empty ( $ string [ $ i - 1 ] ) || $ string [ $ i - 1 ] != "\\" ) ) { $ q = $ q ? false : true ; } else if ( ! $ q && preg_match ( "/$delimiter/" , $ string [ $ i ] ) ) { $ result [ ] = substr ( $ string , $ p , $ i - $ p ) ; $ p = $ i + 1 ; } } $ result [ ] = substr ( $ string , $ p ) ; return $ result ; }

Explode quoted string

@param string $delimiter Delimiter expression string for preg_match()
@param string $string    Input string

@return array            String tokens array
@access private


function encodeHeaderValue($value, $charset, $encoding, $prefix_len=0, $eol="\r\n")
    {
        // #17311: Use multibyte aware method (requires mbstring extension)
        if ($result = Mail_mimePart::encodeMB($value, $charset, $encoding, $prefix_len, $eol)) {
            return $result;
        }

        // Generate the header using the specified params and dynamicly
        // determine the maximum length of such strings.
        // 75 is the value specified in the RFC.
        $encoding = $encoding == 'base64' ? 'B' : 'Q';
        $prefix = '=?' . $charset . '?' . $encoding .'?';
        $suffix = '?=';
        $maxLength = 75 - strlen($prefix . $suffix);
        $maxLength1stLine = $maxLength - $prefix_len;

        if ($encoding == 'B') {
            // Base64 encode the entire string
            $value = base64_encode($value);

            // We can cut base64 every 4 characters, so the real max
            // we can get must be rounded down.
            $maxLength = $maxLength - ($maxLength % 4);
            $maxLength1stLine = $maxLength1stLine - ($maxLength1stLine % 4);

            $cutpoint = $maxLength1stLine;
            $output = '';

            while ($value) {
                // Split translated string at every $maxLength
                $part = substr($value, 0, $cutpoint);
                $value = substr($value, $cutpoint);
                $cutpoint = $maxLength;
                // RFC 2047 specifies that any split header should
                // be separated by a CRLF SPACE.
                if ($output) {
                    $output .= $eol . ' ';
                }
                $output .= $prefix . $part . $suffix;
            }
            $value = $output;
        } else {
            // quoted-printable encoding has been selected
            $value = Mail_mimePart::encodeQP($value);

            // This regexp will break QP-encoded text at every $maxLength
            // but will not break any encoded letters.
            $reg1st = "|(.{0,$maxLength1stLine}[^\=][^\=])|";
            $reg2nd = "|(.{0,$maxLength}[^\=][^\=])|";

            if (strlen($value) > $maxLength1stLine) {
                // Begin with the regexp for the first line.
                $reg = $reg1st;
                $output = '';
                while ($value) {
                    // Split translated string at every $maxLength
                    // But make sure not to break any translated chars.
                    $found = preg_match($reg, $value, $matches);

                    // After this first line, we need to use a different
                    // regexp for the first line.
                    $reg = $reg2nd;

                    // Save the found part and encapsulate it in the
                    // prefix & suffix. Then remove the part from the
                    // $value_out variable.
                    if ($found) {
                        $part = $matches[0];
                        $len = strlen($matches[0]);
                        $value = substr($value, $len);
                    } else {
                        $part = $value;
                        $value = '';
                    }

                    // RFC 2047 specifies that any split header should
                    // be separated by a CRLF SPACE
                    if ($output) {
                        $output .= $eol . ' ';
                    }
                    $output .= $prefix . $part . $suffix;
                }
                $value = $output;
            } else {
                $value = $prefix . $value . $suffix;
            }
        }

        return $value;
    }

Encodes a header value as per RFC2047

@param string $value      The header data to encode
@param string $charset    Character set name
@param string $encoding   Encoding name (base64 or quoted-printable)
@param int    $prefix_len Prefix length. Default: 0
@param string $eol        End-of-line sequence. Default: "\r\n"

@return string            Encoded header data
@access public
@since 1.6.1


function encodeMB($str, $charset, $encoding, $prefix_len=0, $eol="\r\n")
    {
        if (!function_exists('mb_substr') || !function_exists('mb_strlen')) {
            return;
        }

        $encoding = $encoding == 'base64' ? 'B' : 'Q';
        // 75 is the value specified in the RFC
        $prefix = '=?' . $charset . '?'.$encoding.'?';
        $suffix = '?=';
        $maxLength = 75 - strlen($prefix . $suffix);

        // A multi-octet character may not be split across adjacent encoded-words
        // So, we'll loop over each character
        // mb_stlen() with wrong charset will generate a warning here and return null
        $length      = mb_strlen($str, $charset);
        $result      = '';
        $line_length = $prefix_len;

        if ($encoding == 'B') {
            // base64
            $start = 0;
            $prev  = '';

            for ($i=1; $i<=$length; $i++) {
                // See #17311
                $chunk = mb_substr($str, $start, $i-$start, $charset);
                $chunk = base64_encode($chunk);
                $chunk_len = strlen($chunk);

                if ($line_length + $chunk_len == $maxLength || $i == $length) {
                    if ($result) {
                        $result .= "\n";
                    }
                    $result .= $chunk;
                    $line_length = 0;
                    $start = $i;
                } else if ($line_length + $chunk_len > $maxLength) {
                    if ($result) {
                        $result .= "\n";
                    }
                    if ($prev) {
                        $result .= $prev;
                    }
                    $line_length = 0;
                    $start = $i - 1;
                } else {
                    $prev = $chunk;
                }
            }
        } else {
            // quoted-printable
            // see encodeQP()
            $regexp = '/([\x22-\x29\x2C\x2E\x3A-\x40\x5B-\x60\x7B-\x7E\x80-\xFF])/';

            for ($i=0; $i<=$length; $i++) {
                $char = mb_substr($str, $i, 1, $charset);
                // RFC recommends underline (instead of =20) in place of the space
                // that's one of the reasons why we're not using iconv_mime_encode()
                if ($char == ' ') {
                    $char = '_';
                    $char_len = 1;
                } else {
                    $char = preg_replace_callback(
                        $regexp, array('Mail_mimePart', '_qpReplaceCallback'), $char
                    );
                    $char_len = strlen($char);
                }

                if ($line_length + $char_len > $maxLength) {
                    if ($result) {
                        $result .= "\n";
                    }
                    $line_length = 0;
                }

                $result      .= $char;
                $line_length += $char_len;
            }
        }

        if ($result) {
            $result = $prefix
                .str_replace("\n", $suffix.$eol.' '.$prefix, $result).$suffix;
        }

        return $result;
    }

Encodes the given string using base64 or quoted-printable.
This method makes sure that encoded-word represents an integral
number of characters as per RFC2047.

@param string $str        String to encode
@param string $charset    Character set name
@param string $encoding   Encoding name (base64 or quoted-printable)
@param int    $prefix_len Prefix length. Default: 0
@param string $eol        End-of-line sequence. Default: "\r\n"

@return string     Encoded string
@access public
@since 1.8.0

Encodes the given string using base64 or quoted - printable . This method makes sure that encoded - word represents an integral number of characters as per RFC2047 .


public function getMessages()
    {
        $table = new AdminMessages(Message::query());

        $table->with(['recipient', 'sender']);

        if (mustard_loaded('feedback')) {
            $table->with(['recipient.feedbackReceived', 'sender.feedbackReceived']);
        }

        return view('mustard::admin.messages', [
            'table'    => $table,
            'messages' => $table->paginate(),
        ]);
    }

public function getMessages ( ) { $ table = new AdminMessages ( Message :: query ( ) ) ; $ table -> with ( [ 'recipient' , 'sender' ] ) ; if ( mustard_loaded ( 'feedback' ) ) { $ table -> with ( [ 'recipient.feedbackReceived' , 'sender.feedbackReceived' ] ) ; } return view ( 'mustard::admin.messages' , [ 'table' => $ table , 'messages' => $ table -> paginate ( ) , ] ) ; }

Return the admin messages view.

@return \Illuminate\View\View


public function getLine()
    {
        return (feof($this->fp)) ? false : fgets($this->fp, $this->lineReadLength);
    }

public function getLine ( ) { return ( feof ( $ this -> fp ) ) ? false : fgets ( $ this -> fp , $ this -> lineReadLength ) ; }


protected function renderItems($items, $options = [])
    {
        $lines = [];
        foreach ($items as $item) {
            if (is_string($item)) {
                if ($item === static::DIVIDER) {
                    $lines[] = $this->renderDivider();
                } else {
                    $lines[] = $item;
                }
                continue;
            }
            if (isset($item['visible']) && !$item['visible']) {
                continue;
            }
            if (!array_key_exists('label', $item)) {
                throw new InvalidConfigException("The 'label' option is required.");
            }
            $encodeLabel = isset($item['encode']) ? $item['encode'] : $this->encodeLabels;
            $label = $encodeLabel ? $this->htmlHlp->encode($item['label']) : $item['label'];
            $itemOptions = ArrayHelper::getValue($item, 'options', []);
            $linkOptions = ArrayHelper::getValue($item, 'linkOptions', []);
            $itemOptions = ArrayHelper::merge($itemOptions, $linkOptions);
            Html::addCssClass($itemOptions, ['widget' => 'dropdown-item']);
            $url = array_key_exists('url', $item) ? $item['url'] : null;
            if ($url === null) {
                Html::addCssClass($itemOptions, ['widget' => 'dropdown-header']);
                $content = $this->renderHeader($label);
            } else {
                $content = $this->htmlHlp->a($label, $url, $itemOptions);
            }

            $lines[] = $content;
        }

        return $this->htmlHlp->tag('div', implode("\n", $lines), $options);
    }

protected
function
renderItems
(
$
items
,
$
options
=
[
]
)
{
$
lines
=
[
]
;
foreach
(
$
items
as
$
item
)
{
if
(
is_string
(
$
item
)
)
{
if
(
$
item
===
static
::
DIVIDER
)
{
$
lines
[
]
=
$
this
->
renderDivider
(
)
;
}
else
{
$
lines
[
]
=
$
item
;
}
continue
;
}
if
(
isset
(
$
item
[
'visible'
]
)
&&
!
$
item
[
'visible'
]
)
{
continue
;
}
if
(
!
array_key_exists
(
'label'
,
$
item
)
)
{
throw
new
InvalidConfigException
(
"The 'label' option is required."
)
;
}
$
encodeLabel
=
isset
(
$
item
[
'encode'
]
)
$
item
[
'encode'
]
:
$
this
->
encodeLabels
;
$
label
=
$
encodeLabel
$
this
->
htmlHlp
->
encode
(
$
item
[
'label'
]
)
:
$
item
[
'label'
]
;
$
itemOptions
=
ArrayHelper
::
getValue
(
$
item
,
'options'
,
[
]
)
;
$
linkOptions
=
ArrayHelper
::
getValue
(
$
item
,
'linkOptions'
,
[
]
)
;
$
itemOptions
=
ArrayHelper
::
merge
(
$
itemOptions
,
$
linkOptions
)
;
Html
::
addCssClass
(
$
itemOptions
,
[
'widget'
=>
'dropdown-item'
]
)
;
$
url
=
array_key_exists
(
'url'
,
$
item
)
$
item
[
'url'
]
:
;
if
(
$
url
===
)
{
Html
::
addCssClass
(
$
itemOptions
,
[
'widget'
=>
'dropdown-header'
]
)
;
$
content
=
$
this
->
renderHeader
(
$
label
)
;
}
else
{
$
content
=
$
this
->
htmlHlp
->
a
(
$
label
,
$
url
,
$
itemOptions
)
;
}
$
lines
[
]
=
$
content
;
}
return
$
this
->
htmlHlp
->
tag
(
'div'
,
implode
(
"\n"
,
$
lines
)
,
$
options
)
;
}

Renders menu items.
@param array $items the menu items to be rendered
@param array $options the container HTML attributes
@return string the rendering result.
@throws InvalidConfigException if the label option is not specified in one of the items.


public function doBefore() {
        $class_name                    = get_class($this->_controller);
        $this->classAnnotations        = $this->reader->getClassAnnotations($class_name);
        $this->methodAnnotations       = $this->reader->getMethodAnnotations($class_name, $this->_controller->getAction());
    }

public function doBefore ( ) { $ class_name = get_class ( $ this -> _controller ) ; $ this -> classAnnotations = $ this -> reader -> getClassAnnotations ( $ class_name ) ; $ this -> methodAnnotations = $ this -> reader -> getMethodAnnotations ( $ class_name , $ this -> _controller -> getAction ( ) ) ; }

Executes actions before the Controller

@return mixed


public function setOption($name, $value)
    {
        if (!is_string($name)) {
            Zend_Cache::throwException("Incorrect option name!");
        }
        $name = strtolower($name);
        if (array_key_exists($name, $this->_options)) {
            // This is a Core option
            $this->_setOption($name, $value);
            return;
        }
        if (array_key_exists($name, $this->_specificOptions)) {
            // This a specic option of this frontend
            $this->_specificOptions[$name] = $value;
            return;
        }
    }

Public frontend to set an option

There is an additional validation (relatively to the protected _setOption method)

@param  string $name  Name of the option
@param  mixed  $value Value of the option
@throws Zend_Cache_Exception
@return void


public function slug($string, $replacement = '-', $lowercase = true)
    {
        return $this->proxy(__FUNCTION__, [$string, $replacement, $lowercase]);
    }

public function slug ( $ string , $ replacement = '-' , $ lowercase = true ) { return $ this -> proxy ( __FUNCTION__ , [ $ string , $ replacement , $ lowercase ] ) ; }

Returns a string with all spaces converted to given replacement,
non word characters removed and the rest of characters transliterated.

If intl extension isn't available uses fallback that converts latin characters only
and removes the rest. You may customize characters map via $transliteration property
of the helper.

@param string $string An arbitrary string to convert
@param string $replacement The replacement to use for spaces
@param bool $lowercase whether to return the string in lowercase or not. Defaults to `true`.
@return string The converted string.
@see \Reaction\Helpers\Inflector::slug()

Returns a string with all spaces converted to given replacement non word characters removed and the rest of characters transliterated .


public function sentence(array $words, $twoWordsConnector = null, $lastWordConnector = null, $connector = ', ')
    {
        return $this->proxy(__FUNCTION__, [$words, $twoWordsConnector, $lastWordConnector, $connector]);
    }

public
function
sentence
(
array
$
words
,
$
twoWordsConnector
=
,
$
lastWordConnector
=
,
$
connector
=
', '
)
{
return
$
this
->
proxy
(
__FUNCTION__
,
[
$
words
,
$
twoWordsConnector
,
$
lastWordConnector
,
$
connector
]
)
;
}

Converts a list of words into a sentence.

Special treatment is done for the last few words. For example,

```php
$words = ['Spain', 'France'];
echo Inflector::sentence($words);
// output: Spain and France

$words = ['Spain', 'France', 'Italy'];
echo Inflector::sentence($words);
// output: Spain, France and Italy

$words = ['Spain', 'France', 'Italy'];
echo Inflector::sentence($words, ' & ');
// output: Spain, France & Italy
```

@param array $words the words to be converted into an string
@param string $twoWordsConnector the string connecting words when there are only two
@param string $lastWordConnector the string connecting the last two words. If this is null, it will
take the value of `$twoWordsConnector`.
@param string $connector the string connecting words other than those connected by
$lastWordConnector and $twoWordsConnector
@return string the generated sentence
@see \Reaction\Helpers\Inflector::sentence()

Converts a list of words into a sentence .


private function extractGalleryArray($data)
    {
        if ($data->stat == 'fail') {
            return;
        }

        $photoset = &$data->photoset;
        $photo    = $this->newPhoto();

        $gallery                = [];
        $gallery['id']          = $photoset->id;
        $gallery['title']       = $photoset->title->_content;
        $gallery['description'] = $photoset->description->_content;
        $gallery['photos']      = $photo->all($photoset->id);
        $gallery['created']     = (string) $photoset->date_create;
        $gallery['url']         = 'https://www.flickr.com/photos/';
        $gallery['url']         .= $photoset->owner;
        $gallery['url']         .= '/sets/';
        $gallery['url']         .= $photoset->id;
        $gallery['size']        = $photoset->count_photos;
        $gallery['user_id']     = $photoset->owner;
        $gallery['thumbnail']   = $photoset->primary;
        $gallery['views']       = $photoset->count_views;

        return $gallery;

    }

private function extractGalleryArray ( $ data ) { if ( $ data -> stat == 'fail' ) { return ; } $ photoset = & $ data -> photoset ; $ photo = $ this -> newPhoto ( ) ; $ gallery = [ ] ; $ gallery [ 'id' ] = $ photoset -> id ; $ gallery [ 'title' ] = $ photoset -> title -> _content ; $ gallery [ 'description' ] = $ photoset -> description -> _content ; $ gallery [ 'photos' ] = $ photo -> all ( $ photoset -> id ) ; $ gallery [ 'created' ] = ( string ) $ photoset -> date_create ; $ gallery [ 'url' ] = 'https://www.flickr.com/photos/' ; $ gallery [ 'url' ] .= $ photoset -> owner ; $ gallery [ 'url' ] .= '/sets/' ; $ gallery [ 'url' ] .= $ photoset -> id ; $ gallery [ 'size' ] = $ photoset -> count_photos ; $ gallery [ 'user_id' ] = $ photoset -> owner ; $ gallery [ 'thumbnail' ] = $ photoset -> primary ; $ gallery [ 'views' ] = $ photoset -> count_views ; return $ gallery ; }

Extracts the data for the object gallery from the array data given, normalizes them and returns them.

@param  object $data
@return array|null

Extracts the data for the object gallery from the array data given normalizes them and returns them .


public function isValid($session)
    {
        return ($this->getModifiedValue($session)->getTimestamp() + $this->getLifetimeValue($session)) > time();
    }

public function isValid ( $ session ) { return ( $ this -> getModifiedValue ( $ session ) -> getTimestamp ( ) + $ this -> getLifetimeValue ( $ session ) ) > time ( ) ; }

Indicates whether the session is valid.

@param mixed $session

@return bool

Indicates whether the session is valid .


protected function getFieldError($field, $format = ':message')
    {
        $field = $this->flattenFieldName($field);

        if ($this->getErrors()) {
            $allErrors = $this->config->get('html.bootstrap.show_all_errors');

            if ($this->getErrorBag()) {
                $errorBag = $this->getErrors()->{$this->getErrorBag()};
            } else {
                $errorBag = $this->getErrors();
            }

            if ($allErrors) {
                return implode('', $errorBag->get($field, $format));
            }

            return $errorBag->first($field, $format);
        }
    }

Get the first error for a given field, using the provided
format, defaulting to the normal Bootstrap 3 format.

@param  string $field
@param  string $format
@return mixed

Get the first error for a given field using the provided format defaulting to the normal Bootstrap 3 format .


public function setSameSite(string $sameSite = null): self
    {
        if (! \in_array($sameSite, [self::LAX, self::STRICT, null], true)) {
            throw new InvalidSameSiteTypeException(
                'The "sameSite" parameter value is not valid.'
            );
        }

        $this->sameSite = $sameSite;

        return $this;
    }

Set whether the cookie will be available for cross-site requests.

@param string $sameSite

@throws \Valkyrja\Http\Exceptions\InvalidSameSiteTypeException

@return \Valkyrja\HttpMessage\Cookie

Set whether the cookie will be available for cross - site requests .


protected function cleanAndAddHeader()
    {
        if (true === $this->clean || null !== $this->header) {
            foreach ($this->files as $translation) {
                $formatter = FormatterFactory::getInstance($translation);

                if ($this->clean) {
                    $formatter->clean($translation);
                }

                if ($this->header) {
                    $formatter->addHeader($translation, $this->header);
                }
            }
        }
    }

protected function cleanAndAddHeader ( ) { if ( true === $ this -> clean || null !== $ this -> header ) { foreach ( $ this -> files as $ translation ) { $ formatter = FormatterFactory :: getInstance ( $ translation ) ; if ( $ this -> clean ) { $ formatter -> clean ( $ translation ) ; } if ( $ this -> header ) { $ formatter -> addHeader ( $ translation , $ this -> header ) ; } } } }

Clean Crowdin translations and add a header


public static function findClassesPsr4($namespace, $recursively = false, $withoutAutoload = false) {
        $classNames = [];
        if(is_array($namespace)) {
            foreach ($namespace as $ns) {
                $classNames = ArrayHelper::merge($classNames, static::findClassesPsr4($ns, $recursively, $withoutAutoload));
            }
            return $classNames;
        }
        $namespace = trim($namespace, static::CS);
        list($nsPrefix, $namespacePaths) = static::getNamespacePaths($namespace);
        if (empty($namespacePaths)) {
            return [];
        }
        $files = [];
        $regEx = '/\.php$/';
        for ($i = 0; $i < count($namespacePaths); $i++) {
            $dir = $namespacePaths[$i];
            $dirIt = new \RecursiveDirectoryIterator($dir);
            $files = [];
            if($recursively) {
                foreach(new \RecursiveIteratorIterator($dirIt) as $file)
                {
                    $fileStr = (string)$file;
                    if (!preg_match($regEx, $fileStr)) {
                        continue;
                    }
                    $fileStr = substr($fileStr, strlen($dir) + 1, -4);
                    $files[] = $fileStr;
                }
            } else {
                $_files = glob($dir . static::DS . '*.php');
                for ($j = 0; $j < count($_files); $j++) {
                    $fileStr = $_files[$j];
                    $fileStr = substr($fileStr, strlen($dir) + 1, -4);
                    $files[] = $fileStr;
                }
            }
        }

        for ($i = 0; $i < count($files); $i++) {
            $fileStr = $files[$i];
            $className = $namespace . static::CS . str_replace(static::DS, static::CS, $fileStr);
            if ($withoutAutoload || class_exists($className, true)) {
                $classNames[] = $className;
            }
        }
        return $classNames;
    }

public static function findClassesPsr4 ( $ namespace , $ recursively = false , $ withoutAutoload = false ) { $ classNames = [ ] ; if ( is_array ( $ namespace ) ) { foreach ( $ namespace as $ ns ) { $ classNames = ArrayHelper :: merge ( $ classNames , static :: findClassesPsr4 ( $ ns , $ recursively , $ withoutAutoload ) ) ; } return $ classNames ; } $ namespace = trim ( $ namespace , static :: CS ) ; list ( $ nsPrefix , $ namespacePaths ) = static :: getNamespacePaths ( $ namespace ) ; if ( empty ( $ namespacePaths ) ) { return [ ] ; } $ files = [ ] ; $ regEx = '/\.php$/' ; for ( $ i = 0 ; $ i < count ( $ namespacePaths ) ; $ i ++ ) { $ dir = $ namespacePaths [ $ i ] ; $ dirIt = new \ RecursiveDirectoryIterator ( $ dir ) ; $ files = [ ] ; if ( $ recursively ) { foreach ( new \ RecursiveIteratorIterator ( $ dirIt ) as $ file ) { $ fileStr = ( string ) $ file ; if ( ! preg_match ( $ regEx , $ fileStr ) ) { continue ; } $ fileStr = substr ( $ fileStr , strlen ( $ dir ) + 1 , - 4 ) ; $ files [ ] = $ fileStr ; } } else { $ _files = glob ( $ dir . static :: DS . '*.php' ) ; for ( $ j = 0 ; $ j < count ( $ _files ) ; $ j ++ ) { $ fileStr = $ _files [ $ j ] ; $ fileStr = substr ( $ fileStr , strlen ( $ dir ) + 1 , - 4 ) ; $ files [ ] = $ fileStr ; } } } for ( $ i = 0 ; $ i < count ( $ files ) ; $ i ++ ) { $ fileStr = $ files [ $ i ] ; $ className = $ namespace . static :: CS . str_replace ( static :: DS , static :: CS , $ fileStr ) ; if ( $ withoutAutoload || class_exists ( $ className , true ) ) { $ classNames [ ] = $ className ; } } return $ classNames ; }

Find class names inside given namespace
@param string|array $namespace
@param bool         $recursively Search recursively is namespace directory
@param bool         $withoutAutoload Do not check class names through 'class_exist(name, true)'
@return array


public static function getNamespacePath($namespace, $first = true)
    {
        $namespace = trim($namespace, static::CS);
        $nsPrefixes = static::getNamespacePrefixes($namespace);
        $loaderPrefixes = static::getLoaderPrefixes();
        $nsSuffix = '';
        foreach ($nsPrefixes as $prefix) {
            if (!isset($loaderPrefixes[$prefix])) {
                continue;
            }
            $nsSuffix = trim(mb_substr($namespace, mb_strlen($prefix)), static::CS);
            $paths = $loaderPrefixes[$prefix];
            break;
        }
        if (!isset($paths)) {
            return $first ? null : [];
        }
        $results = [];
        foreach ($paths as $path) {
            $result = $path . static::DS . str_replace('\\', static::DS, $nsSuffix);
            if (!file_exists($result) || !is_dir($result)) {
                continue;
            }
            if ($first) {
                return $result;
            }
            $results[] = $result;
        }
        return $results;
    }

public static function getNamespacePath ( $ namespace , $ first = true ) { $ namespace = trim ( $ namespace , static :: CS ) ; $ nsPrefixes = static :: getNamespacePrefixes ( $ namespace ) ; $ loaderPrefixes = static :: getLoaderPrefixes ( ) ; $ nsSuffix = '' ; foreach ( $ nsPrefixes as $ prefix ) { if ( ! isset ( $ loaderPrefixes [ $ prefix ] ) ) { continue ; } $ nsSuffix = trim ( mb_substr ( $ namespace , mb_strlen ( $ prefix ) ) , static :: CS ) ; $ paths = $ loaderPrefixes [ $ prefix ] ; break ; } if ( ! isset ( $ paths ) ) { return $ first ? null : [ ] ; } $ results = [ ] ; foreach ( $ paths as $ path ) { $ result = $ path . static :: DS . str_replace ( '\\' , static :: DS , $ nsSuffix ) ; if ( ! file_exists ( $ result ) || ! is_dir ( $ result ) ) { continue ; } if ( $ first ) { return $ result ; } $ results [ ] = $ result ; } return $ results ; }

Get namespace directory path
@param string $namespace
@param bool $first
@return array|mixed|null|string


protected static function getNamespacePaths($namespace) {
        $paths = [];
        $namespace = trim($namespace, static::CS);
        $nsPrefixes = static::getNamespacePrefixes($namespace);
        $nsPrefixesCount = count($nsPrefixes);
        $loaderPrefixes = static::getLoaderPrefixes();
        $nsPrefix = null;
        for ($i = 0; $i < $nsPrefixesCount; $i++) {
            $nsPrefix = $nsPrefixes[$i];
            if (!isset($loaderPrefixes[$nsPrefix])) {
                continue;
            }
            if ($nsPrefix === $namespace) {
                return $loaderPrefixes[$nsPrefix];
            }
            $nsSuffix = trim(substr($namespace, strlen($nsPrefix)), static::CS);
            $nsSuffix = str_replace(static::CS, static::DS, $nsSuffix);
            $loaderPaths = $loaderPrefixes[$nsPrefix];
            $loaderPathsCount = count($loaderPaths);
            for ($j = 0; $j < $loaderPathsCount; $j++) {
                $possiblePath = $loaderPaths[$j] . static::DS . $nsSuffix;
                if(file_exists($possiblePath) && is_dir($possiblePath)) { $paths[] = $possiblePath; }
            }
            if (!empty($paths)) {
                break;
            }
        }
        if (empty($paths)) {
            return [null, []];
        }

        return [$nsPrefix, $paths];
    }

protected static function getNamespacePaths ( $ namespace ) { $ paths = [ ] ; $ namespace = trim ( $ namespace , static :: CS ) ; $ nsPrefixes = static :: getNamespacePrefixes ( $ namespace ) ; $ nsPrefixesCount = count ( $ nsPrefixes ) ; $ loaderPrefixes = static :: getLoaderPrefixes ( ) ; $ nsPrefix = null ; for ( $ i = 0 ; $ i < $ nsPrefixesCount ; $ i ++ ) { $ nsPrefix = $ nsPrefixes [ $ i ] ; if ( ! isset ( $ loaderPrefixes [ $ nsPrefix ] ) ) { continue ; } if ( $ nsPrefix === $ namespace ) { return $ loaderPrefixes [ $ nsPrefix ] ; } $ nsSuffix = trim ( substr ( $ namespace , strlen ( $ nsPrefix ) ) , static :: CS ) ; $ nsSuffix = str_replace ( static :: CS , static :: DS , $ nsSuffix ) ; $ loaderPaths = $ loaderPrefixes [ $ nsPrefix ] ; $ loaderPathsCount = count ( $ loaderPaths ) ; for ( $ j = 0 ; $ j < $ loaderPathsCount ; $ j ++ ) { $ possiblePath = $ loaderPaths [ $ j ] . static :: DS . $ nsSuffix ; if ( file_exists ( $ possiblePath ) && is_dir ( $ possiblePath ) ) { $ paths [ ] = $ possiblePath ; } } if ( ! empty ( $ paths ) ) { break ; } } if ( empty ( $ paths ) ) { return [ null , [ ] ] ; } return [ $ nsPrefix , $ paths ] ; }

Get possible namespace paths
@param string $namespace
@return array|mixed


protected static function getNamespacePrefixes($namespace) {
        $namespaceExp = explode(static::CS, trim($namespace, static::CS));
        $namespaceExpCount = count($namespaceExp);
        if ($namespaceExpCount === 1) {
            return $namespaceExp;
        }
        $prefixes = [];
        $currPrefix = '';
        for ($i = 0; $i < $namespaceExpCount; $i++) {
            $currPrefix .= static::CS . $namespaceExp[$i];
            $prefixes[] = trim($currPrefix, static::CS);
        }
        $prefixes = array_reverse($prefixes);
        return $prefixes;
    }

protected static function getNamespacePrefixes ( $ namespace ) { $ namespaceExp = explode ( static :: CS , trim ( $ namespace , static :: CS ) ) ; $ namespaceExpCount = count ( $ namespaceExp ) ; if ( $ namespaceExpCount === 1 ) { return $ namespaceExp ; } $ prefixes = [ ] ; $ currPrefix = '' ; for ( $ i = 0 ; $ i < $ namespaceExpCount ; $ i ++ ) { $ currPrefix .= static :: CS . $ namespaceExp [ $ i ] ; $ prefixes [ ] = trim ( $ currPrefix , static :: CS ) ; } $ prefixes = array_reverse ( $ prefixes ) ; return $ prefixes ; }

Explode namespace to possible prefixes
@param string $namespace
@return array


protected static function getLoaderPrefixes() {
        $loader = static::getLoader();
        $_prefixes = [
            [],
            $loader->getPrefixesPsr4(),
        ];
        $_prefixes = ArrayHelper::merge(...$_prefixes);
        $prefixes = [];
        foreach ($_prefixes as $prefix => $paths) {
            $prefix = trim($prefix, '\\');
            $_paths = [];
            for ($i = 0; $i < count($paths); $i++) { $_paths[] = realpath($paths[$i]); }
            $prefixes[$prefix] = $_paths;
        }
        return $prefixes;
    }

protected static function getLoaderPrefixes ( ) { $ loader = static :: getLoader ( ) ; $ _prefixes = [ [ ] , $ loader -> getPrefixesPsr4 ( ) , ] ; $ _prefixes = ArrayHelper :: merge ( ... $ _prefixes ) ; $ prefixes = [ ] ; foreach ( $ _prefixes as $ prefix => $ paths ) { $ prefix = trim ( $ prefix , '\\' ) ; $ _paths = [ ] ; for ( $ i = 0 ; $ i < count ( $ paths ) ; $ i ++ ) { $ _paths [ ] = realpath ( $ paths [ $ i ] ) ; } $ prefixes [ $ prefix ] = $ _paths ; } return $ prefixes ; }


public function updateSession()
    {
        $existingSession = $this->getSession();
        if ($this->form) {
            $filters = $this->form->getData() + $this->filterDefaults();
        } else {
            $filters = $this->filterDefaults();
        }

        $currentValues = [
            'filters' => $filters,
            'page' => $this->pageFromQuery(),
        ];

        $newSession = array_merge($this->sessionDefaults(), $existingSession, $currentValues);

        $this->session->set($this->sessionKey, $newSession);
    }

public function updateSession ( ) { $ existingSession = $ this -> getSession ( ) ; if ( $ this -> form ) { $ filters = $ this -> form -> getData ( ) + $ this -> filterDefaults ( ) ; } else { $ filters = $ this -> filterDefaults ( ) ; } $ currentValues = [ 'filters' => $ filters , 'page' => $ this -> pageFromQuery ( ) , ] ; $ newSession = array_merge ( $ this -> sessionDefaults ( ) , $ existingSession , $ currentValues ) ; $ this -> session -> set ( $ this -> sessionKey , $ newSession ) ; }

Sets the key in the session.
The filters are merged with the defaults as well as the data for
this "filter" in the session.

Sets the key in the session . The filters are merged with the defaults as well as the data for this filter in the session .


public function mergeSession(array $newValues)
    {
        $existing = $this->getSession();

        $new = array_merge($existing, $newValues);

        $this->session->set($this->sessionKey, $new);
    }

public function mergeSession ( array $ newValues ) { $ existing = $ this -> getSession ( ) ; $ new = array_merge ( $ existing , $ newValues ) ; $ this -> session -> set ( $ this -> sessionKey , $ new ) ; }

Merges the passed array with the session data and updates the session.

@param  array  $newValues The values in the session to replace.

Merges the passed array with the session data and updates the session .


public function getSession($key = null)
    {
        // merge the arrays, using the default values if not in the session
        $sessionData = (array) $this->session->get($this->sessionKey) + $this->sessionDefaults();

        if (null === $key) {
            return $sessionData;
        } else if (array_key_exists($key, $sessionData)) {
            return $sessionData[$key];
        } else {
            return null;
        }
    }

Gets all or a single key from the session.

@param  string $key The session key to retrieve or null for the entire session.

@return mixed|null

Gets all or a single key from the session .


public function pageFromQuery()
    {
        if ($this->request) {
            $page = $this->request->query->getInt('page');
        } else {
            $page = 0;
        }

        return ($page > 0) ? $page : 1;
    }

public function pageFromQuery ( ) { if ( $ this -> request ) { $ page = $ this -> request -> query -> getInt ( 'page' ) ; } else { $ page = 0 ; } return ( $ page > 0 ) ? $ page : 1 ; }

Returns the current page from the query.
If the page is not set, it will return page 1.

@return int

Returns the current page from the query . If the page is not set it will return page 1 .


public function query()
    {
        $queryData = [
            self::FORM_BLOCK_NAME => $this->getFiltersAsArray(),
            'page'                => $this->getSession('page'),
        ];

        return http_build_query($queryData);
    }

public function query ( ) { $ queryData = [ self :: FORM_BLOCK_NAME => $ this -> getFiltersAsArray ( ) , 'page' => $ this -> getSession ( 'page' ) , ] ; return http_build_query ( $ queryData ) ; }

Returns the query string based on the filters and page in the session.

@return string

Returns the query string based on the filters and page in the session .