PEAR_Validate::_validPackageName()

PEAR_Validate::_validPackageName()  -- Override this method to handle validation of normal package names

Synopsis

require_once '/Validate.php';

bool PEAR_Validate::_validPackageName (string $name)

Description

This protected method can be used to change the normal package validation scheme. By default, all packages must begin with a letter and contain only letters, numbers and underscores. Using this method, it is possible to change this entirely to enforce another scheme.

For instance, enforcing java-style com.blah.package package names can be done simply by this code:

<?php
require_once 'PEAR/Validate.php';
class MyChannel_Validate extends PEAR_Validate
{
    function _validPackageName($name)
    {
        return preg_match('/[a-zA-Z][a-zA-Z0-9_]*(\.[a-zA-Z0-9_]+)*/', $name);
    }
}
?>

Then, by using a customized channel validation package, the installer will enforce java-style package names for your channel.

Parameter

string $name

package name string to test for validity.

Throws

throws no exceptions thrown

Note

This function can not be called statically.