.PHONY: check run test clean help

PHP ?= php
LOAD = require "Aip56.php"; $$aip56 = \Akadata\Aip56\Aip56::selfContained()

check:
	$(PHP) -l Aip56.php
	$(PHP) -r '$(LOAD); $$aip56->validate(); echo "AIP-56 PHP class validation: OK", PHP_EOL;'

run:
	$(PHP) -r '$(LOAD); echo $$aip56->generate(), PHP_EOL;'

test:
	$(PHP) -r '$(LOAD); $$phrase = $$aip56->generate(); if ($$aip56->wordCount() !== 9074 || $$aip56->chunkCount() !== 26 || preg_match("/^(?:[A-Za-z]{5} ){14}[A-Za-z]{5}$$/", $$phrase) !== 1) { throw new RuntimeException("AIP-56 PHP class smoke test failed"); } echo "AIP-56 PHP class smoke test: OK", PHP_EOL;'

clean:
	rm -f .aip56-test.tmp

help:
	@printf '%s\n' \
		'make check  Lint the class and validate the canonical wordlist' \
		'make run    Generate one AIP-56 phrase' \
		'make test   Run the dependency-free PHP smoke test' \
		'make clean  Remove temporary local artifacts' \
		'make help   Show these targets'
