silverorange Code


Swat.SwatAutoloaderRule
/Swat/SwatAutoloaderRule.php at line 38

Class SwatAutoloaderRule

SwatObject
└─SwatAutoloaderRule

public class SwatAutoloaderRule
extends SwatObject

A class autoloader rule

Class autoloader rules define how class names map to filenames. An autoloader rule consists of three parts:

The expression of an autoloader rule is a regular expression using PERL syntax that matches a class name in PHP. For example, the expression '/^Swat(*.)$/' matches all Swat classes.

The replacement of an autoloader rule is a string representing the filename format of classes matched by the autoloader expression. The filename format may contain substitution markers denoted by $n where n is the n'th captured parenthesized subpattern. For example, the replacement 'Swat/Swat$1.php' represents the file naming convention for Swat class files. The format of replacement strings is intentionally similar to Apache rewrite rule syntax.

Whether or not an autoloader rule is final determines what happens if a class name matches a rule. If a rule is final, the class name is not checked against any other rules once a match is found. Rules are final by default.

Copyright:
2006 silverorange
License:
http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
See Also:
SwatAutoloader

Constructor Summary

SwatAutoloaderRule(string expression, string replacement, boolean last)

Creates a new class autoloader rule.

Method Summary
string

apply(string class_name)

Applies this autoloader rule to a class name.

boolean

isLast()

Whether or not this rule is a final rule.

Constructor Detail

/Swat/SwatAutoloaderRule.php at line 57

SwatAutoloaderRule

public SwatAutoloaderRule(string expression, string replacement, boolean last)

Creates a new class autoloader rule

Parameters:
expression - the expression of this rule. Uses PERL regular expression syntax.
replacement - the replacement format string of this rule.
last - whether or not this rule is final.

Method Detail

/Swat/SwatAutoloaderRule.php at line 89

apply

public string apply(string class_name)

Applies this autoloader rule to a class name

Parameters:
class_name - the name of the class to apply this rule to.
Returns:
the filename the class name maps to if the filename matches this rule, or null if the filename does not match this rule.

/Swat/SwatAutoloaderRule.php at line 72

isLast

public boolean isLast()

Whether or not this rule is a final rule

Returns:
whether or not this rule is a final rule.

silverorange Code