public function validateCustomSnippet($name, $type, $priority)
    {
        $snippetName = str_replace(' ', '', $name);
        $types = ['init', 'recv', 'hit', 'miss', 'pass', 'fetch', 'error', 'deliver', 'log', 'hash', 'none'];

        $inArray = in_array($type, $types);
        $isNumeric = is_numeric($priority);
        $isAlphanumeric = preg_match('/^[\w]+$/', $snippetName);
        $error = null;

        if (!$inArray) {
            $error = 'Type value is not recognised.';
            return [
                'snippet_name' => null,
                'error' => $error
            ];
        }
        if (!$isNumeric) {
            $error = 'Please make sure that the priority value is a number.';
            return [
                'snippet_name' => null,
                'error' => $error
            ];
        }
        if (!$isAlphanumeric) {
            $error = 'Please make sure that the name value contains only alphanumeric characters.';
            return [
                'snippet_name' => null,
                'error' => $error
            ];
        }
        return [
            'snippet_name' => $snippetName,
            'error' => $error
        ];
    }
public function validateCustomSnippet($name, $type, $priority)
    {
        $snippetName = str_replace(' ', '', $name);
        $types = ['init', 'recv', 'hit', 'miss', 'pass', 'fetch', 'error', 'deliver', 'log', 'hash', 'none'];

        $inArray = in_array($type, $types);
        $isNumeric = is_numeric($priority);
        $isAlphanumeric = preg_match('/^[\w]+$/', $snippetName);
        $error = null;

        if (!$inArray) {
            $error = 'Type value is not recognised.';
            return [
                'snippet_name' => null,
                'error' => $error
            ];
        }
        if (!$isNumeric) {
            $error = 'Please make sure that the priority value is a number.';
            return [
                'snippet_name' => null,
                'error' => $error
            ];
        }
        if (!$isAlphanumeric) {
            $error = 'Please make sure that the name value contains only alphanumeric characters.';
            return [
                'snippet_name' => null,
                'error' => $error
            ];
        }
        return [
            'snippet_name' => $snippetName,
            'error' => $error
        ];
    }
public function validateCustomSnippet ( $ name , $ type , $ priority ) { $ snippetName = str_replace ( ' ' , '' , $ name ) ; $ types = [ 'init' , 'recv' , 'hit' , 'miss' , 'pass' , 'fetch' , 'error' , 'deliver' , 'log' , 'hash' , 'none' ] ; $ inArray = in_array ( $ type , $ types ) ; $ isNumeric = is_numeric ( $ priority ) ; $ isAlphanumeric = preg_match ( '/^[\w]+$/' , $ snippetName ) ; $ error = null ; if ( ! $ inArray ) { $ error = 'Type value is not recognised.' ; return [ 'snippet_name' => null , 'error' => $ error ] ; } if ( ! $ isNumeric ) { $ error = 'Please make sure that the priority value is a number.' ; return [ 'snippet_name' => null , 'error' => $ error ] ; } if ( ! $ isAlphanumeric ) { $ error = 'Please make sure that the name value contains only alphanumeric characters.' ; return [ 'snippet_name' => null , 'error' => $ error ] ; } return [ 'snippet_name' => $ snippetName , 'error' => $ error ] ; }
Validate custom snippet data

@param $name
@param $type
@param $priority
@return array
Validate custom snippet data