diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
index 81c7b58..cec36ab 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -1,10 +1,9 @@
---
name: Bug report
about: Create a report to help us improve
-title: ''
-labels: 'bug'
-assignees: ''
-
+title: ""
+labels: "bug"
+assignees: ""
---
**Describe the bug**
@@ -12,6 +11,7 @@ A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
+
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
@@ -24,15 +24,17 @@ A clear and concise description of what you expected to happen.
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- - OS: [e.g. iOS]
- - Browser [e.g. chrome, safari]
- - Version [e.g. 22]
+
+- OS: [e.g. iOS]
+- Browser [e.g. chrome, safari]
+- Version [e.g. 22]
**Smartphone (please complete the following information):**
- - Device: [e.g. iPhone6]
- - OS: [e.g. iOS8.1]
- - Browser [e.g. stock browser, safari]
- - Version [e.g. 22]
+
+- Device: [e.g. iPhone6]
+- OS: [e.g. iOS8.1]
+- Browser [e.g. stock browser, safari]
+- Version [e.g. 22]
**Additional context**
Add any other context about the problem here.
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
index 36014cd..9b90523 100644
--- a/.github/ISSUE_TEMPLATE/feature_request.md
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -1,10 +1,9 @@
---
name: Feature request
about: Suggest an idea for this project
-title: ''
-labels: 'enhancement'
-assignees: ''
-
+title: ""
+labels: "enhancement"
+assignees: ""
---
**Is your feature request related to a problem? Please describe.**
diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md
index 7696922..c52d5cd 100644
--- a/.github/ISSUE_TEMPLATE/question.md
+++ b/.github/ISSUE_TEMPLATE/question.md
@@ -1,14 +1,11 @@
---
name: Question
about: I have a question about this project
-title: ''
-labels: 'question'
-assignees: ''
-
+title: ""
+labels: "question"
+assignees: ""
---
-
**Description**
A brief description of the question or issue:
-
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
index 99cb136..223c041 100644
--- a/CODE_OF_CONDUCT.md
+++ b/CODE_OF_CONDUCT.md
@@ -17,23 +17,23 @@ diverse, inclusive, and healthy community.
Examples of behavior that contributes to a positive environment for our
community include:
-* Demonstrating empathy and kindness toward other people
-* Being respectful of differing opinions, viewpoints, and experiences
-* Giving and gracefully accepting constructive feedback
-* Accepting responsibility and apologizing to those affected by our mistakes,
+- Demonstrating empathy and kindness toward other people
+- Being respectful of differing opinions, viewpoints, and experiences
+- Giving and gracefully accepting constructive feedback
+- Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
-* Focusing on what is best not just for us as individuals, but for the overall
+- Focusing on what is best not just for us as individuals, but for the overall
community
Examples of unacceptable behavior include:
-* The use of sexualized language or imagery, and sexual attention or advances of
+- The use of sexualized language or imagery, and sexual attention or advances of
any kind
-* Trolling, insulting or derogatory comments, and personal or political attacks
-* Public or private harassment
-* Publishing others' private information, such as a physical or email address,
+- Trolling, insulting or derogatory comments, and personal or political attacks
+- Public or private harassment
+- Publishing others' private information, such as a physical or email address,
without their explicit permission
-* Other conduct which could reasonably be considered inappropriate in a
+- Other conduct which could reasonably be considered inappropriate in a
professional setting
## Enforcement Responsibilities
@@ -119,14 +119,14 @@ version 2.1, available at
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
Community Impact Guidelines were inspired by
-[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
+[Mozilla's code of conduct enforcement ladder][mozilla coc].
For answers to common questions about this code of conduct, see the FAQ at
-[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
+[https://www.contributor-covenant.org/faq][faq]. Translations are available at
[https://www.contributor-covenant.org/translations][translations].
[homepage]: https://www.contributor-covenant.org
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
-[Mozilla CoC]: https://github.com/mozilla/diversity
-[FAQ]: https://www.contributor-covenant.org/faq
+[mozilla coc]: https://github.com/mozilla/diversity
+[faq]: https://www.contributor-covenant.org/faq
[translations]: https://www.contributor-covenant.org/translations
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index c2c22ea..32bbadc 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -8,8 +8,8 @@ Make sure your request is meaningful and you have tested the app locally before
#### Requirements
-* [PHP 7.4+](https://www.apachefriends.org/index.html)
-* [Composer](https://getcomposer.org)
+- [PHP 7.4+](https://www.apachefriends.org/index.html)
+- [Composer](https://getcomposer.org)
#### Linux
@@ -53,14 +53,17 @@ composer install
### Format and test the code
Run the following command to format the code with Prettier:
+
```
composer run format
```
Run the following command to check if your code is formatted properly:
+
```
composer run format:check
```
+
> **Note** You need to have [`prettier`](https://prettier.io/) and the [prettier-php plugin](https://github.com/prettier/plugin-php) installed globally in order to run this command.
Run the following command to run the PHPUnit test script which will verify that the tested functionality is still working.
diff --git a/README.md b/README.md
index 740d40b..17805ad 100644
--- a/README.md
+++ b/README.md
@@ -137,7 +137,9 @@ Refer to [CONTRIBUTING.md](/CONTRIBUTING.md) for more details on contributing, i
Made with ❤️ and PHP
+
+
This project uses [Twemoji](https://github.com/twitter/twemoji), published under the [CC-BY 4.0 License](https://creativecommons.org/licenses/by/4.0/)
diff --git a/src/controllers/RendererController.php b/src/controllers/RendererController.php
index 45a0bc4..5cf5dcd 100644
--- a/src/controllers/RendererController.php
+++ b/src/controllers/RendererController.php
@@ -1,11 +1,10 @@
-
-
>
+>
⌨️ Readme Typing SVG
@@ -155,7 +155,7 @@
- ">
+ ">
diff --git a/src/demo/js/script.js b/src/demo/js/script.js
index 4e35c76..60d5566 100644
--- a/src/demo/js/script.js
+++ b/src/demo/js/script.js
@@ -26,22 +26,20 @@ let preview = {
update: function () {
const copyButtons = document.querySelectorAll(".copy-button");
// get parameter values from all .param elements
- const params = Array.from(document.querySelectorAll(".param:not([data-index])")).reduce(
- (acc, next) => {
- // copy accumulator into local object
- let obj = acc;
- let value = next.value;
- // remove hash from any colors and remove "FF" if full opacity
- value = value.replace(/^#([A-Fa-f0-9]{6})(?:[Ff]{2})?/, "$1");
- // add value to reduction accumulator
- obj[next.id] = value;
- return obj;
- }, {}
- );
+ const params = Array.from(document.querySelectorAll(".param:not([data-index])")).reduce((acc, next) => {
+ // copy accumulator into local object
+ let obj = acc;
+ let value = next.value;
+ // remove hash from any colors and remove "FF" if full opacity
+ value = value.replace(/^#([A-Fa-f0-9]{6})(?:[Ff]{2})?/, "$1");
+ // add value to reduction accumulator
+ obj[next.id] = value;
+ return obj;
+ }, {});
const lineInputs = Array.from(document.querySelectorAll(".param[data-index]"));
// disable copy button if any line contains semicolon
if (lineInputs.some((el) => el.value.indexOf(";") >= 0)) {
- return copyButtons.forEach((el) => el.disabled = true);
+ return copyButtons.forEach((el) => (el.disabled = true));
}
// add lines to parameters
params.lines = lineInputs
@@ -50,7 +48,7 @@ let preview = {
.join(";"); // join lines with ';' delimiter
// function to URI encode string but keep semicolons as ';' and spaces as '+'
const encode = (str) => {
- return encodeURIComponent(str).replace(/%3B/g, ";").replace(/%20/g, "+")
+ return encodeURIComponent(str).replace(/%3B/g, ";").replace(/%20/g, "+");
};
// convert parameters to query string
const query = Object.keys(params)
@@ -77,7 +75,7 @@ let preview = {
mdElement.innerText = md;
htmlElement.innerText = html;
// disable copy button if no lines are filled in
- copyButtons.forEach((el) => el.disabled = !params.lines.length);
+ copyButtons.forEach((el) => (el.disabled = !params.lines.length));
},
addLine: function () {
const parent = document.querySelector(".lines");
@@ -101,11 +99,9 @@ let preview = {
// removal button
const deleteButton = document.createElement("button");
deleteButton.className = "delete-line btn";
- deleteButton.setAttribute(
- "onclick",
- "return preview.removeLine(this.dataset.index);"
- );
- deleteButton.innerHTML = '';
+ deleteButton.setAttribute("onclick", "return preview.removeLine(this.dataset.index);");
+ deleteButton.innerHTML =
+ '';
deleteButton.dataset.index = index;
// add elements
@@ -124,40 +120,35 @@ let preview = {
index = Number(index);
const parent = document.querySelector(".lines");
// remove all elements for given property
- parent
- .querySelectorAll(`[data-index="${index}"]`)
- .forEach((el) => {
- parent.removeChild(el);
- });
+ parent.querySelectorAll(`[data-index="${index}"]`).forEach((el) => {
+ parent.removeChild(el);
+ });
// update index numbers
const labels = parent.querySelectorAll("label");
- labels
- .forEach((label) => {
- const labelIndex = Number(label.dataset.index);
- if (labelIndex > index) {
- label.dataset.index = labelIndex - 1;
- label.setAttribute("for", `line-${labelIndex - 1}`);
- label.innerText = `Line ${labelIndex - 1}`;
- }
- });
+ labels.forEach((label) => {
+ const labelIndex = Number(label.dataset.index);
+ if (labelIndex > index) {
+ label.dataset.index = labelIndex - 1;
+ label.setAttribute("for", `line-${labelIndex - 1}`);
+ label.innerText = `Line ${labelIndex - 1}`;
+ }
+ });
const inputs = parent.querySelectorAll(".param");
- inputs
- .forEach((input) => {
- const inputIndex = Number(input.dataset.index);
- if (inputIndex > index) {
- input.dataset.index = inputIndex - 1;
- input.setAttribute("id", `line-${inputIndex - 1}`);
- input.setAttribute("name", `line-${inputIndex - 1}`);
- }
- });
+ inputs.forEach((input) => {
+ const inputIndex = Number(input.dataset.index);
+ if (inputIndex > index) {
+ input.dataset.index = inputIndex - 1;
+ input.setAttribute("id", `line-${inputIndex - 1}`);
+ input.setAttribute("name", `line-${inputIndex - 1}`);
+ }
+ });
const buttons = parent.querySelectorAll(".delete-line.btn");
- buttons
- .forEach((button) => {
- const buttonIndex = Number(button.dataset.index);
- if (buttonIndex > index) {
- button.dataset.index = buttonIndex - 1;
- }
- });
+ buttons.forEach((button) => {
+ const buttonIndex = Number(button.dataset.index);
+ if (buttonIndex > index) {
+ button.dataset.index = buttonIndex - 1;
+ }
+ });
// disable button if only 1
buttons[0].disabled = buttons.length == 1;
// update and exit
diff --git a/src/demo/js/toggle-dark.js b/src/demo/js/toggle-dark.js
index ab0d6ff..0101f81 100644
--- a/src/demo/js/toggle-dark.js
+++ b/src/demo/js/toggle-dark.js
@@ -1,7 +1,5 @@
// enable dark mode on load if user prefers dark themes and has not used the toggle
-getCookie("darkmode") === null &&
- window.matchMedia("(prefers-color-scheme: dark)").matches &&
- darkmode();
+getCookie("darkmode") === null && window.matchMedia("(prefers-color-scheme: dark)").matches && darkmode();
function toggleTheme() {
// turn on dark mode
diff --git a/src/index.php b/src/index.php
index 7b684a8..304ceaa 100644
--- a/src/index.php
+++ b/src/index.php
@@ -1,6 +1,6 @@
- $font,
- "text" => $text,
- "display" => "fallback",
- ]);
+ $url =
+ "https://fonts.googleapis.com/css2?" .
+ http_build_query([
+ "family" => $font,
+ "text" => $text,
+ "display" => "fallback",
+ ]);
try {
// get the CSS for the font
$response = self::curlGetContents($url);
diff --git a/src/models/RendererModel.php b/src/models/RendererModel.php
index 984671d..d71e960 100644
--- a/src/models/RendererModel.php
+++ b/src/models/RendererModel.php
@@ -50,7 +50,7 @@ class RendererModel
public $template;
/** @var array $DEFAULTS */
- private $DEFAULTS = array(
+ private $DEFAULTS = [
"font" => "monospace",
"color" => "#36BCF7",
"background" => "#00000000",
@@ -62,7 +62,7 @@ class RendererModel
"multiline" => "false",
"duration" => "5000",
"pause" => "0",
- );
+ ];
/**
* Construct RendererModel
@@ -99,7 +99,7 @@ class RendererModel
if (!$lines) {
throw new InvalidArgumentException("Lines parameter must be set.");
}
- $trimmed_lines = rtrim($lines, ';');
+ $trimmed_lines = rtrim($lines, ";");
$exploded = explode(";", $trimmed_lines);
// escape special characters to prevent code injection
return array_map("htmlspecialchars", $exploded);
diff --git a/src/templates/main.php b/src/templates/main.php
index 48b4420..cf767c0 100644
--- a/src/templates/main.php
+++ b/src/templates/main.php
@@ -5,38 +5,43 @@
style='background-color: = $background ?>;'
width='= $width ?>px' height='= $height ?>px'>
- = preg_replace("/\n/", "\n\t", $fontCSS); ?>
+ = preg_replace("/\n/", "\n\t", $fontCSS) ?>
-
+
-
+
-
+
-
+ begin='0s;= "d" . (count($lines) - 1) ?>.end' keyTimes="0;= $i / ($i + 1) ?>;= $i / ($i + 1) +
+ $duration / (($duration + $pause) * ($i + 1)) ?>;1"
+ values='m0,= ($i + 1) * $lineHeight ?> h0 ; m0,= ($i + 1) * $lineHeight ?> h0 ; m0,= ($i + 1) *
+ $lineHeight ?> h= $width ?> ; m0,= ($i + 1) * $lineHeight ?> h= $width ?>' />
+
dominant-baseline='middle'
dominant-baseline='auto'
-
+
x='50%' text-anchor='middle'>
x='0%' text-anchor='start'>
-
+
= $lines[$i] . "\n" ?>
-
-
+
+
diff --git a/src/views/ErrorView.php b/src/views/ErrorView.php
index 7f234ca..8d1b51c 100644
--- a/src/views/ErrorView.php
+++ b/src/views/ErrorView.php
@@ -1,4 +1,4 @@
- $this->model->lines,
"font" => $this->model->font,
"color" => $this->model->color,
@@ -40,7 +40,7 @@ class RendererView
"fontCSS" => $this->model->fontCSS,
"duration" => $this->model->duration,
"pause" => $this->model->pause,
- ));
+ ]);
// render SVG with output buffering
ob_start();
include $this->model->template;
diff --git a/tests/OptionsTest.php b/tests/OptionsTest.php
index f09624d..b11e997 100644
--- a/tests/OptionsTest.php
+++ b/tests/OptionsTest.php
@@ -4,11 +4,10 @@ declare(strict_types=1);
use PHPUnit\Framework\TestCase;
-require 'vendor/autoload.php';
+require "vendor/autoload.php";
final class OptionsTest extends TestCase
{
-
/**
* Test exception thrown when missing 'lines' parameter
*/
@@ -16,11 +15,11 @@ final class OptionsTest extends TestCase
{
$this->expectException("InvalidArgumentException");
$this->expectExceptionMessage("Lines parameter must be set.");
- $params = array(
+ $params = [
"center" => "true",
"width" => "380",
"height" => "50",
- );
+ ];
print_r(new RendererModel("src/templates/main.php", $params));
}
@@ -29,10 +28,10 @@ final class OptionsTest extends TestCase
*/
public function testValidFont(): void
{
- $params = array(
+ $params = [
"lines" => "text",
"font" => "Open Sans",
- );
+ ];
$model = new RendererModel("src/templates/main.php", $params);
$this->assertEquals("Open Sans", $model->font);
}
@@ -42,10 +41,10 @@ final class OptionsTest extends TestCase
*/
public function testValidFontColor(): void
{
- $params = array(
+ $params = [
"lines" => "text",
"color" => "000000",
- );
+ ];
$model = new RendererModel("src/templates/main.php", $params);
$this->assertEquals("#000000", $model->color);
}
@@ -55,10 +54,10 @@ final class OptionsTest extends TestCase
*/
public function testInvalidFontColor(): void
{
- $params = array(
+ $params = [
"lines" => "text",
"color" => "00000",
- );
+ ];
$model = new RendererModel("src/templates/main.php", $params);
$this->assertEquals("#36BCF7", $model->color);
}
@@ -68,10 +67,10 @@ final class OptionsTest extends TestCase
*/
public function testValidBackgroundColor(): void
{
- $params = array(
+ $params = [
"lines" => "text",
"background" => "00000033",
- );
+ ];
$model = new RendererModel("src/templates/main.php", $params);
$this->assertEquals("#00000033", $model->background);
}
@@ -81,10 +80,10 @@ final class OptionsTest extends TestCase
*/
public function testInvalidBackgroundColor(): void
{
- $params = array(
+ $params = [
"lines" => "text",
"background" => "00000",
- );
+ ];
$model = new RendererModel("src/templates/main.php", $params);
$this->assertEquals("#00000000", $model->background);
}
@@ -94,10 +93,10 @@ final class OptionsTest extends TestCase
*/
public function testValidFontSize(): void
{
- $params = array(
+ $params = [
"lines" => "text",
"size" => "18",
- );
+ ];
$model = new RendererModel("src/templates/main.php", $params);
$this->assertEquals(18, $model->size);
}
@@ -109,10 +108,10 @@ final class OptionsTest extends TestCase
{
$this->expectException("InvalidArgumentException");
$this->expectExceptionMessage("Font size must be a positive number.");
- $params = array(
+ $params = [
"lines" => "text",
"size" => "0",
- );
+ ];
print_r(new RendererModel("src/templates/main.php", $params));
}
@@ -121,10 +120,10 @@ final class OptionsTest extends TestCase
*/
public function testValidHeight(): void
{
- $params = array(
+ $params = [
"lines" => "text",
"height" => "80",
- );
+ ];
$model = new RendererModel("src/templates/main.php", $params);
$this->assertEquals(80, $model->height);
}
@@ -136,10 +135,10 @@ final class OptionsTest extends TestCase
{
$this->expectException("InvalidArgumentException");
$this->expectExceptionMessage("Height must be a positive number.");
- $params = array(
+ $params = [
"lines" => "text",
"height" => "x",
- );
+ ];
print_r(new RendererModel("src/templates/main.php", $params));
}
@@ -148,10 +147,10 @@ final class OptionsTest extends TestCase
*/
public function testValidWidth(): void
{
- $params = array(
+ $params = [
"lines" => "text",
"width" => "500",
- );
+ ];
$model = new RendererModel("src/templates/main.php", $params);
$this->assertEquals(500, $model->width);
}
@@ -163,10 +162,10 @@ final class OptionsTest extends TestCase
{
$this->expectException("InvalidArgumentException");
$this->expectExceptionMessage("Width must be a positive number.");
- $params = array(
+ $params = [
"lines" => "text",
"width" => "-1",
- );
+ ];
print_r(new RendererModel("src/templates/main.php", $params));
}
@@ -175,10 +174,10 @@ final class OptionsTest extends TestCase
*/
public function testCenterIsTrue(): void
{
- $params = array(
+ $params = [
"lines" => "text",
"center" => "true",
- );
+ ];
$model = new RendererModel("src/templates/main.php", $params);
$this->assertEquals(true, $model->center);
}
@@ -188,10 +187,10 @@ final class OptionsTest extends TestCase
*/
public function testCenterIsNotTrue(): void
{
- $params = array(
+ $params = [
"lines" => "text",
"center" => "other",
- );
+ ];
$model = new RendererModel("src/templates/main.php", $params);
$this->assertEquals(false, $model->center);
}
@@ -201,10 +200,10 @@ final class OptionsTest extends TestCase
*/
public function testVCenterIsTrue(): void
{
- $params = array(
+ $params = [
"lines" => "text",
"vCenter" => "true",
- );
+ ];
$model = new RendererModel("src/templates/main.php", $params);
$this->assertEquals(true, $model->vCenter);
}
@@ -214,10 +213,10 @@ final class OptionsTest extends TestCase
*/
public function testVCenterIsNotTrue(): void
{
- $params = array(
+ $params = [
"lines" => "text",
"vCenter" => "other",
- );
+ ];
$model = new RendererModel("src/templates/main.php", $params);
$this->assertEquals(false, $model->vCenter);
}
@@ -227,10 +226,10 @@ final class OptionsTest extends TestCase
*/
public function testValidDuration(): void
{
- $params = array(
+ $params = [
"lines" => "text",
"duration" => "500",
- );
+ ];
$model = new RendererModel("src/templates/main.php", $params);
$this->assertEquals(500, $model->duration);
}
@@ -242,10 +241,10 @@ final class OptionsTest extends TestCase
{
$this->expectException("InvalidArgumentException");
$this->expectExceptionMessage("duration must be a positive number.");
- $params = array(
+ $params = [
"lines" => "text",
"duration" => "-1",
- );
+ ];
print_r(new RendererModel("src/templates/main.php", $params));
}
@@ -254,10 +253,10 @@ final class OptionsTest extends TestCase
*/
public function testValidPause(): void
{
- $params = array(
+ $params = [
"lines" => "text",
"pause" => "500",
- );
+ ];
$model = new RendererModel("src/templates/main.php", $params);
$this->assertEquals(500, $model->pause);
}
@@ -267,10 +266,10 @@ final class OptionsTest extends TestCase
*/
public function testValidPauseZero(): void
{
- $params = array(
+ $params = [
"lines" => "text",
"pause" => "0",
- );
+ ];
$model = new RendererModel("src/templates/main.php", $params);
$this->assertEquals(0, $model->pause);
}
@@ -282,10 +281,10 @@ final class OptionsTest extends TestCase
{
$this->expectException("InvalidArgumentException");
$this->expectExceptionMessage("pause must be a non-negative number.");
- $params = array(
+ $params = [
"lines" => "text",
"pause" => "-1",
- );
+ ];
print_r(new RendererModel("src/templates/main.php", $params));
}
}
diff --git a/tests/RendererTest.php b/tests/RendererTest.php
index ae22a04..73a4c81 100644
--- a/tests/RendererTest.php
+++ b/tests/RendererTest.php
@@ -4,47 +4,46 @@ declare(strict_types=1);
use PHPUnit\Framework\TestCase;
-require 'vendor/autoload.php';
+require "vendor/autoload.php";
final class RendererTest extends TestCase
{
-
/**
* Test normal card render
*/
public function testCardRender(): void
{
- $params = array(
- "lines" => implode(";", array(
+ $params = [
+ "lines" => implode(";", [
"Full-stack web and app developer",
"Self-taught UI/UX Designer",
"10+ years of coding experience",
"Always learning new things",
- )),
+ ]),
"center" => "true",
"vCenter" => "true",
"width" => "380",
"height" => "50",
- );
+ ];
$controller = new RendererController($params);
$this->assertEquals(file_get_contents("tests/svg/test_normal.svg"), $controller->render());
}
public function testMultilineCardRender(): void
{
- $params = array(
- "lines" => implode(";", array(
+ $params = [
+ "lines" => implode(";", [
"Full-stack web and app developer",
"Self-taught UI/UX Designer",
"10+ years of coding experience",
"Always learning new things",
- )),
+ ]),
"center" => "true",
"vCenter" => "true",
"width" => "380",
"height" => "200",
"multiline" => "true",
- );
+ ];
$controller = new RendererController($params);
$this->assertEquals(file_get_contents("tests/svg/test_multiline.svg"), $controller->render());
}
@@ -55,12 +54,12 @@ final class RendererTest extends TestCase
public function testErrorCardRender(): void
{
// missing lines
- $params = array(
+ $params = [
"center" => "true",
"vCenter" => "true",
"width" => "380",
"height" => "50",
- );
+ ];
$controller = new RendererController($params);
$this->assertEquals(file_get_contents("tests/svg/test_missing_lines.svg"), $controller->render());
}
@@ -70,10 +69,10 @@ final class RendererTest extends TestCase
*/
public function testLoadingGoogleFont(): void
{
- $params = array(
+ $params = [
"lines" => "text",
"font" => "Roboto",
- );
+ ];
$controller = new RendererController($params);
$expected = preg_replace("/\/\*(.*?)\*\//", "", file_get_contents("tests/svg/test_fonts.svg"));
$actual = preg_replace("/\/\*(.*?)\*\//", "", $controller->render());
@@ -85,18 +84,18 @@ final class RendererTest extends TestCase
*/
public function testInvalidGoogleFont(): void
{
- $params = array(
- "lines" => implode(";", array(
+ $params = [
+ "lines" => implode(";", [
"Full-stack web and app developer",
"Self-taught UI/UX Designer",
"10+ years of coding experience",
"Always learning new things",
- )),
+ ]),
"center" => "true",
"vCenter" => "true",
"width" => "380",
"font" => "Not-A-Font",
- );
+ ];
$controller = new RendererController($params);
$expected = str_replace('"monospace"', '"Not-A-Font"', file_get_contents("tests/svg/test_normal.svg"));
$this->assertEquals($expected, $controller->render());
@@ -107,19 +106,19 @@ final class RendererTest extends TestCase
*/
public function testLineTrimming(): void
{
- $params = array(
- "lines" => implode(";", array(
+ $params = [
+ "lines" => implode(";", [
"Full-stack web and app developer",
"Self-taught UI/UX Designer",
"10+ years of coding experience",
"Always learning new things",
"",
- )),
+ ]),
"center" => "true",
"vCenter" => "true",
"width" => "380",
"height" => "50",
- );
+ ];
$controller = new RendererController($params);
$this->assertEquals(file_get_contents("tests/svg/test_normal.svg"), $controller->render());
}
@@ -129,17 +128,17 @@ final class RendererTest extends TestCase
*/
public function testNormalVerticalAlignment(): void
{
- $params = array(
- "lines" => implode(";", array(
+ $params = [
+ "lines" => implode(";", [
"Full-stack web and app developer",
"Self-taught UI/UX Designer",
"10+ years of coding experience",
"Always learning new things",
- )),
+ ]),
"center" => "true",
"width" => "380",
"height" => "50",
- );
+ ];
$controller = new RendererController($params);
$this->assertEquals(file_get_contents("tests/svg/test_normal_vertical_alignment.svg"), $controller->render());
}
@@ -149,19 +148,19 @@ final class RendererTest extends TestCase
*/
public function testPauseParameter(): void
{
- $params = array(
- "lines" => implode(";", array(
+ $params = [
+ "lines" => implode(";", [
"Full-stack web and app developer",
"Self-taught UI/UX Designer",
"10+ years of coding experience",
"Always learning new things",
- )),
+ ]),
"center" => "true",
"vCenter" => "true",
"width" => "380",
"height" => "50",
"pause" => "1000",
- );
+ ];
$controller = new RendererController($params);
$this->assertEquals(file_get_contents("tests/svg/test_pause.svg"), $controller->render());
}
@@ -171,20 +170,20 @@ final class RendererTest extends TestCase
*/
public function testPauseMultiline(): void
{
- $params = array(
- "lines" => implode(";", array(
+ $params = [
+ "lines" => implode(";", [
"Full-stack web and app developer",
"Self-taught UI/UX Designer",
"10+ years of coding experience",
"Always learning new things",
- )),
+ ]),
"center" => "true",
"vCenter" => "true",
"width" => "380",
"height" => "200",
"multiline" => "true",
"pause" => "1000",
- );
+ ];
$controller = new RendererController($params);
$this->assertEquals(file_get_contents("tests/svg/test_pause_multiline.svg"), $controller->render());
}