From 0ecc4a7b734d636e911c3a3b7889eea92bbb9523 Mon Sep 17 00:00:00 2001 From: Pekka Laiho Date: Tue, 16 Jun 2020 20:43:47 +0700 Subject: [PATCH] add values for PI and newline to library --- src/Lib/Math.php | 4 ++++ src/Lib/Strings.php | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/Lib/Math.php b/src/Lib/Math.php index 72d9f50..f7cacb7 100644 --- a/src/Lib/Math.php +++ b/src/Lib/Math.php @@ -8,6 +8,10 @@ class Math implements ILib { public function register(Env $env): void { + // Constants + + $env->set('pi', \M_PI); + // Basic arithmetic $env->set('+', new CoreFunc('+', 'Return the sum of all arguments.', 1, -1, diff --git a/src/Lib/Strings.php b/src/Lib/Strings.php index 2537050..4b1679c 100644 --- a/src/Lib/Strings.php +++ b/src/Lib/Strings.php @@ -9,6 +9,8 @@ class Strings implements ILib { public function register(Env $env): void { + $env->set('ln', \PHP_EOL); + $env->set('trim', new CoreFunc('trim', 'Remove whitespace from beginning and end of string.', 1, 1, fn (string $a) => trim($a) ));