Skip to content

Commit 882d886

Browse files
committed
first project/step five/added asciinema, brain-even
1 parent 7c4acfa commit 882d886

File tree

6 files changed

+226
-4
lines changed

6 files changed

+226
-4
lines changed

.idea/php.xml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ install:
44
brain-games:
55
bin/brain-games
66

7+
brain-even:
8+
bin/brain-even
9+
710
validate:
811
composer validate
912

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@
99
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=Eksi-tech_php-project-45&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=Eksi-tech_php-project-45)
1010
[![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=Eksi-tech_php-project-45&metric=sqale_index)](https://sonarcloud.io/summary/new_code?id=Eksi-tech_php-project-45)
1111
[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=Eksi-tech_php-project-45&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=Eksi-tech_php-project-45)
12-
[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=Eksi-tech_php-project-45&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=Eksi-tech_php-project-45)
12+
[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=Eksi-tech_php-project-45&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=Eksi-tech_php-project-45)
13+
https://asciinema.org/a/PZIB0AMPHDWAigwTO2UAGq9PI

bin/brain-even

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/env php
2+
3+
<?php
4+
5+
require_once __DIR__ . '/../vendor/autoload.php';
6+
7+
use function cli\line;
8+
use function cli\prompt;
9+
10+
line('Welcome to the Brain Game!');
11+
$name = prompt('May I have your name?');
12+
line("Hello, %s!", $name);
13+
14+
line('Answer "yes" if the number is even, otherwise answer "no".');
15+
$winningCounter = 0;
16+
function isEven($number)
17+
{
18+
return $number % 2 === 0;
19+
}
20+
21+
while ($winningCounter < 3) {
22+
$number = rand(1, 20);
23+
line('Question:' . "{$number}");
24+
$answer = prompt('Your answer');
25+
26+
if (isEven($number)) {
27+
28+
if ($answer === 'yes') {
29+
line("Correct!");
30+
$winningCounter++;
31+
}
32+
elseif ($answer === 'no' || $answer != "yes") {
33+
line("'$answer' is wrong answer ;(. Correct answer was 'yes'.
34+
Let's try again, $name!");
35+
break;
36+
}
37+
}else{
38+
if ($answer === 'yes'|| $answer != "no") {
39+
line("'$answer' is wrong answer ;(. Correct answer was 'no'.
40+
Let's try again, $name!");
41+
break;
42+
}
43+
elseif ($answer === 'no') {
44+
line("Correct!");
45+
$winningCounter++;
46+
}
47+
}
48+
if ($winningCounter === 3) {
49+
line("Congratulations, $name!");
50+
}
51+
}
52+
53+
54+
55+
56+
57+
58+

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"wp-cli/php-cli-tools": "^0.12.6"
1414
},
1515
"bin": [
16-
"bin/brain-games"
16+
"bin/brain-games",
17+
"bin/brain-even"
1718
],
1819
"autoload": {
1920
"psr-4": {

game-installation.cast

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
{"version": 2, "width": 120, "height": 30, "timestamp": 1762508545, "env": {"SHELL": "/bin/bash", "TERM": "xterm-256color"}}
2+
[0.024096, "o", "\u001b[?2004h\u001b]0;wasex@DESKTOP-G9HIGVK: ~/php-project-45\u0007\u001b[01;32mwasex@DESKTOP-G9HIGVK\u001b[00m:\u001b[01;34m~/php-project-45\u001b[00m$ "]
3+
[0.914739, "o", "r"]
4+
[1.75753, "o", "m"]
5+
[2.197517, "o", " "]
6+
[2.65943, "o", "-"]
7+
[3.502824, "o", "r"]
8+
[3.818133, "o", "f"]
9+
[3.935487, "o", " "]
10+
[5.820233, "o", "v"]
11+
[6.296747, "o", "e"]
12+
[6.63006, "o", "ndor/"]
13+
[7.978034, "o", " "]
14+
[8.122201, "o", "c"]
15+
[8.394149, "o", "o"]
16+
[8.618757, "o", "m"]
17+
[8.842271, "o", "p"]
18+
[9.058333, "o", "o"]
19+
[9.162249, "o", "s"]
20+
[9.378186, "o", "e"]
21+
[9.8617, "o", "\u0007r."]
22+
[10.651595, "o", "\u0007"]
23+
[11.501917, "o", "l"]
24+
[11.763513, "o", "ock "]
25+
[14.773996, "o", "\r\n\u001b[?2004l\r"]
26+
[14.891526, "o", "\u001b[?2004h\u001b]0;wasex@DESKTOP-G9HIGVK: ~/php-project-45\u0007\u001b[01;32mwasex@DESKTOP-G9HIGVK\u001b[00m:\u001b[01;34m~/php-project-45\u001b[00m$ "]
27+
[16.724406, "o", "l"]
28+
[16.820788, "o", "s"]
29+
[17.030314, "o", " "]
30+
[17.296154, "o", "-"]
31+
[17.561917, "o", "l"]
32+
[17.658759, "o", "a"]
33+
[17.828133, "o", "\r\n\u001b[?2004l\r"]
34+
[17.831699, "o", "total 48\r\n"]
35+
[17.831901, "o", "drwxr-xr-x 7 wasex wasex 4096 Nov 7 12:42 \u001b[0m\u001b[01;34m.\u001b[0m\r\ndrwxr-x--- 14 wasex wasex 4096 Nov 6 20:22 \u001b[01;34m..\u001b[0m\r\ndrwxr-xr-x 8 wasex wasex 4096 Nov 6 20:22 \u001b[01;34m.git\u001b[0m\r\ndrwxr-xr-x 3 wasex wasex 4096 Nov 6 17:25 \u001b[01;34m.github\u001b[0m\r\n-rw-r--r-- 1 wasex wasex 9 Nov 6 17:30 .gitignore\r\ndrwxr-xr-x 2 wasex wasex 4096 Nov 7 12:40 \u001b[01;34m.idea\u001b[0m\r\n-rw-r--r-- 1 wasex wasex 198 Nov 6 21:18 Makefile\r\n-rw-r--r-- 1 wasex wasex 2126 Nov 6 19:29 README.md\r\ndrwxr-xr-x 2 wasex wasex 4096 Nov 6 21:43 \u001b[01;34mbin\u001b[0m\r\n-rw-r--r-- 1 wasex wasex 588 Nov 6 21:27 composer.json\r\n-rw-r--r-- 1 wasex wasex 1163 Nov 7 12:42 game-installation.cast\r\ndrwxr-xr-x 2 wasex wasex 4096 Nov 6 20:18 \u001b[01;34msrc\u001b[0m\r\n"]
36+
[17.832336, "o", "\u001b[?2004h\u001b]0;wasex@DESKTOP-G9HIGVK: ~/php-project-45\u0007\u001b[01;32mwasex@DESKTOP-G9HIGVK\u001b[00m:\u001b[01;34m~/php-project-45\u001b[00m$ "]
37+
[21.053439, "o", "m"]
38+
[21.14154, "o", "a"]
39+
[21.310066, "o", "k"]
40+
[22.072831, "o", "e"]
41+
[22.564247, "o", " "]
42+
[22.982201, "o", "i"]
43+
[23.194804, "o", "n"]
44+
[23.224169, "o", "s"]
45+
[23.473462, "o", "t"]
46+
[23.583436, "o", "a"]
47+
[23.722945, "o", "l"]
48+
[23.847457, "o", "l"]
49+
[24.360963, "o", "\r\n\u001b[?2004l\r"]
50+
[24.365552, "o", "composer install\r\n"]
51+
[24.622619, "o", "\u001b[30;43mNo composer.lock file present. Updating dependencies to latest instead of installing from lock file. See https://getcomposer.org/install for more information.\u001b[39;49m\r\n"]
52+
[24.622959, "o", "\u001b[32mLoading composer repositories with package information\u001b[39m\r\n"]
53+
[24.918271, "o", "\u001b[32mUpdating dependencies\u001b[39m\r\n"]
54+
[24.925856, "o", "\u001b[32mLock file operations: 2 installs, 0 updates, 0 removals\u001b[39m\r\n - Locking \u001b[32msquizlabs/php_codesniffer\u001b[39m (\u001b[33m4.0.0\u001b[39m)\r\n - Locking \u001b[32mwp-cli/php-cli-tools\u001b[39m (\u001b[33mv0.12.6\u001b[39m)\r\n"]
55+
[24.926412, "o", "\u001b[32mWriting lock file\u001b[39m\r\n"]
56+
[24.926631, "o", "\u001b[32mInstalling dependencies from lock file (including require-dev)\u001b[39m\r\n"]
57+
[24.927767, "o", "\u001b[32mPackage operations: 2 installs, 0 updates, 0 removals\u001b[39m\r\n"]
58+
[25.007933, "o", " 0 [>---------------------------]\u001b[1G\u001b[2K 0 [->--------------------------]"]
59+
[25.008147, "o", "\u001b[1G\u001b[2K 0 [--->------------------------]\u001b[1G\u001b[2K"]
60+
[25.008351, "o", " - Installing \u001b[32msquizlabs/php_codesniffer\u001b[39m (\u001b[33m4.0.0\u001b[39m): Extracting archive\r\n"]
61+
[25.011173, "o", " - Installing \u001b[32mwp-cli/php-cli-tools\u001b[39m (\u001b[33mv0.12.6\u001b[39m): Extracting archive\r\n"]
62+
[25.013065, "o", " 0/2 [>---------------------------] 0%"]
63+
[25.11328, "o", "\u001b[1G\u001b[2K 1/2 [==============>-------------] 50%"]
64+
[25.124849, "o", "\u001b[1G\u001b[2K 2/2 [============================] 100%\u001b[1G\u001b[2K"]
65+
[25.324785, "o", "\u001b[32mGenerating autoload files\u001b[39m\r\n"]
66+
[25.326926, "o", "\u001b[32m1 package you are using is looking for funding.\u001b[39m\r\n\u001b[32mUse the `composer fund` command to find out more!\u001b[39m\r\n"]
67+
[25.345007, "o", "\u001b[?2004h\u001b]0;wasex@DESKTOP-G9HIGVK: ~/php-project-45\u0007\u001b[01;32mwasex@DESKTOP-G9HIGVK\u001b[00m:\u001b[01;34m~/php-project-45\u001b[00m$ "]
68+
[29.758179, "o", "l"]
69+
[29.84607, "o", "s"]
70+
[29.985245, "o", " "]
71+
[30.16112, "o", "-"]
72+
[31.518243, "o", "\b\u001b[K"]
73+
[32.053516, "o", "-"]
74+
[32.280799, "o", "l"]
75+
[32.368858, "o", "a"]
76+
[32.478815, "o", " "]
77+
[32.684258, "o", "v"]
78+
[33.358816, "o", "e"]
79+
[33.677317, "o", "ndor/"]
80+
[35.761437, "o", "\r\n\u001b[?2004l\r"]
81+
[35.763424, "o", "total 28\r\ndrwxr-xr-x 6 wasex wasex 4096 Nov 7 12:42 \u001b[0m\u001b[01;34m.\u001b[0m\r\n"]
82+
[35.76361, "o", "drwxr-xr-x 8 wasex wasex 4096 Nov 7 12:42 \u001b[01;34m..\u001b[0m\r\n-rw-r--r-- 1 wasex wasex 748 Nov 7 12:42 autoload.php\r\ndrwxr-xr-x 2 wasex wasex 4096 Nov 7 12:42 \u001b[01;34mbin\u001b[0m\r\ndrwxr-xr-x 2 wasex wasex 4096 Nov 7 12:42 \u001b[01;34mcomposer\u001b[0m\r\ndrwxr-xr-x 3 wasex wasex 4096 Nov 7 12:42 \u001b[01;34msquizlabs\u001b[0m\r\ndrwxr-xr-x 3 wasex wasex 4096 Nov 7 12:42 \u001b[01;34mwp-cli\u001b[0m\r\n"]
83+
[35.763923, "o", "\u001b[?2004h\u001b]0;wasex@DESKTOP-G9HIGVK: ~/php-project-45\u0007\u001b[01;32mwasex@DESKTOP-G9HIGVK\u001b[00m:\u001b[01;34m~/php-project-45\u001b[00m$ "]
84+
[38.52934, "o", "m"]
85+
[38.585315, "o", "a"]
86+
[38.753416, "o", "k"]
87+
[38.841385, "o", "e"]
88+
[39.049485, "o", " "]
89+
[39.577345, "o", "b"]
90+
[40.073387, "o", "r"]
91+
[41.80941, "o", "a"]
92+
[42.045821, "o", "i"]
93+
[42.294478, "o", "n"]
94+
[42.576467, "o", "-"]
95+
[43.247819, "o", "e"]
96+
[43.438554, "o", "v"]
97+
[43.54626, "o", "e"]
98+
[44.300844, "o", "n"]
99+
[44.648829, "o", "\r\n\u001b[?2004l\r"]
100+
[44.651355, "o", "bin/brain-even\r\n"]
101+
[44.68335, "o", "\r\n"]
102+
[44.685015, "o", "Welcome to the Brain Game!\r\n"]
103+
[44.685247, "o", "May I have your name?: "]
104+
[48.222889, "o", "V"]
105+
[48.541936, "o", "i"]
106+
[48.725931, "o", "k"]
107+
[48.813956, "o", "t"]
108+
[48.94993, "o", "o"]
109+
[49.141978, "o", "r"]
110+
[49.453702, "o", "\r\n"]
111+
[49.454053, "o", "Hello, Viktor!\r\n"]
112+
[49.454201, "o", "Answer \"yes\" if the number is even, otherwise answer \"no\".\r\n"]
113+
[49.454311, "o", "Question:6\r\n"]
114+
[49.454477, "o", "Your answer: "]
115+
[51.428177, "o", "y"]
116+
[51.655626, "o", "r"]
117+
[52.000271, "o", "s"]
118+
[52.220301, "o", "\b \b"]
119+
[52.352131, "o", "\b \b"]
120+
[52.476724, "o", "e"]
121+
[52.675105, "o", "s"]
122+
[52.887763, "o", "\r\n"]
123+
[52.888031, "o", "Correct!\r\n"]
124+
[52.888199, "o", "Question:14\r\nYour answer: "]
125+
[54.860426, "o", "y"]
126+
[54.99241, "o", "e"]
127+
[55.248982, "o", "s"]
128+
[55.52775, "o", "\r\n"]
129+
[55.527982, "o", "Correct!\r\n"]
130+
[55.528127, "o", "Question:2\r\nYour answer: "]
131+
[56.253674, "o", "y"]
132+
[56.392949, "o", "e"]
133+
[56.613031, "o", "s"]
134+
[56.803651, "o", "\r\n"]
135+
[56.803751, "o", "Correct!\r\n"]
136+
[56.804017, "o", "Congratulations, Viktor!\r\n"]
137+
[56.808602, "o", "\u001b[?2004h\u001b]0;wasex@DESKTOP-G9HIGVK: ~/php-project-45\u0007\u001b[01;32mwasex@DESKTOP-G9HIGVK\u001b[00m:\u001b[01;34m~/php-project-45\u001b[00m$ "]
138+
[58.497741, "o", "make brain-even"]
139+
[59.165061, "o", "\r\n\u001b[?2004l\r"]
140+
[59.166905, "o", "bin/brain-even\r\n"]
141+
[59.186446, "o", "\r\n"]
142+
[59.188181, "o", "Welcome to the Brain Game!\r\nMay I have your name?: "]
143+
[61.174415, "o", "V"]
144+
[61.350468, "o", "i"]
145+
[61.526367, "o", "k"]
146+
[61.629062, "o", "t"]
147+
[61.819704, "o", "o"]
148+
[61.922412, "o", "r"]
149+
[62.267015, "o", "\r\n"]
150+
[62.267342, "o", "Hello, Viktor!\r\n"]
151+
[62.267495, "o", "Answer \"yes\" if the number is even, otherwise answer \"no\".\r\n"]
152+
[62.267657, "o", "Question:9\r\nYour answer: "]
153+
[64.070993, "o", "y"]
154+
[64.173708, "o", "e"]
155+
[64.393621, "o", "s"]
156+
[64.628306, "o", "\r\n"]
157+
[64.628535, "o", "'yes' is wrong answer ;(. Correct answer was 'no'.\r\nLet's try again, Viktor!\r\n"]
158+
[64.633218, "o", "\u001b[?2004h\u001b]0;wasex@DESKTOP-G9HIGVK: ~/php-project-45\u0007\u001b[01;32mwasex@DESKTOP-G9HIGVK\u001b[00m:\u001b[01;34m~/php-project-45\u001b[00m$ "]
159+
[71.271081, "o", "\u001b[?2004l\r\r\nexit\r\n"]

0 commit comments

Comments
 (0)