CloudObjects / Directory / Lukas Rosenstock / AsciiArtFunctions
Sign in

AsciiArtFunctions

a phpmae:Class in Lukas Rosenstock
Public PHP Methods
  • getSnailWithSign(string $textForSign)

    Draws an AsciiArt snail holding a sign with the specified text.

Source Code
<?php

/**
 * Implementation for coid://lukasrosenstock.net/AsciiArtFunctions
 */
class AsciiArtFunctions {

    /**
     * Draws an AsciiArt snail holding a sign with the specified text.
     */
    public function getSnailWithSign(string $textForSign) {
        $snail = [
            '        ____',
            ' \  /  / /\ \\',
            ' [..]  |__/ |',
            '  ||________/'
        ];

        $prefixLength = strlen($textForSign) + 6;
        $output = [];
        for ($i = 0; $i < 4; $i++) {
            $line = '';
            switch ($i) {
                case 0:
                    for ($j = 0; $j < $prefixLength; $j++)
                        $line .= ' ';
                    break;
                case 1:
                case 3:
                    for ($j = 0; $j < $prefixLength - 2; $j++)
                        $line .= '-';
                    $line .= '  ';
                    break;
                case 2:
                    $line .= '| '.$textForSign.' |->';
                    break;
            }
            $line .= $snail[$i];
            $output[] = $line;
        }

        return implode("\n", $output);
    }

}
Meta
URI / COID
coid://lukasrosenstock.net/AsciiArtFunctions content_copy
Revision
4-7118892ef8c5c6e5c363848e1b4cd861 content_copy
Last updated
2020-08-07 18:02 (UTC)
Usage permission
co:Public
Objects in this namespace