Skip to content

Extension points

phil/spam-protection

The library is plain PHP: it declares no service and no port, and its classes are final. Each check is a value the application configures and calls; the checks that need state are the application's, and their signals are the library's.

PointHow
The secret of the tokensThe secret given to TokenCodec, at least 16 bytes, from the application's secrets
How long a form may takenew TimingPolicy(minimum: …, maximum: …)
The cost of the proofnew ProofOfWork(difficulty: …), from 0 to ProofOfWork::MAXIMUM_DIFFICULTY
The content rulesnew ContentRules(maximumLinks: …, forbiddenTerms: […], detectGibberish: …, maximumLength: …): the terms are the application's list
Tokens submitted twiceThe application's store of used nonces raises Signal::TokenReplayed
Rate limitingThe application's rate limiter raises Signal::RateLimited
The hidden fieldThe application's form raises Signal::HoneypotFilled
What a held submission becomesInspection::isSpam() and has(): the application decides — refuse, queue for moderation, ask again

The signals are a closed enum: a check of the application's own that has no matching signal keeps its result beside the inspection rather than in it.