Skip to content

Commit 2010aae

Browse files
committed
Feedback changes
1 parent 3be44ac commit 2010aae

File tree

4 files changed

+8
-43
lines changed

4 files changed

+8
-43
lines changed

app/Component/AddTask.pre

-9
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,15 @@
22

33
namespace App\Component;
44

5-
use InvalidArgumentException;
6-
75
class AddTask
86
{
97
public function render($props)
108
{
11-
assert($this->hasValid($props));
12-
139
return (
1410
<form method={"post"} action={"/add"} className={"add-task"}>
1511
<input name={"text"} type={"text"} />
1612
<button type={"submit"}>add</button>
1713
</form>
1814
);
1915
}
20-
21-
private function hasValid($props)
22-
{
23-
return true;
24-
}
2516
}

app/Component/TaskList.pre

-9
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,10 @@
22

33
namespace App\Component;
44

5-
use InvalidArgumentException;
6-
75
class TaskList
86
{
97
public function render($props)
108
{
11-
assert($this->hasValid($props));
12-
139
{ $children } = $props;
1410

1511
return (
@@ -19,11 +15,6 @@ class TaskList
1915
);
2016
}
2117

22-
private function hasValid($props)
23-
{
24-
return true;
25-
}
26-
2718
private function children($children)
2819
{
2920
if (count($children)) {

pre.lock

-1
This file was deleted.

server.pre

+8-24
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
11
<?php
22

3-
use App\Component\AddTask;
4-
use App\Component\Page;
5-
use App\Component\TaskList;
63
use Silex\Application;
74
use Silex\Provider\SessionServiceProvider;
85
use Symfony\Component\HttpFoundation\Request;
96

7+
use App\Component\AddTask;
8+
use App\Component\Page;
9+
use App\Component\TaskList;
10+
1011
$app = new Application();
1112
$app->register(new SessionServiceProvider());
12-
$app["debug"] = true;
1313

1414
$app->get("/", (Request $request) => {
1515
$session = $request->getSession();
1616

17-
$tasks = $session->get("tasks");
18-
19-
if (!$tasks) {
20-
$tasks = [];
21-
}
17+
$tasks = $session->get("tasks", []);
2218

2319
return (
2420
<Page>
@@ -31,16 +27,8 @@ $app->get("/", (Request $request) => {
3127
$app->post("/add", (Request $request) => {
3228
$session = $request->getSession();
3329

34-
$id = $session->get("id");
35-
$tasks = $session->get("tasks");
36-
37-
if (!$id) {
38-
$id = 0;
39-
}
40-
41-
if (!$tasks) {
42-
$tasks = [];
43-
}
30+
$id = $session->get("id", 0);
31+
$tasks = $session->get("tasks", []);
4432

4533
$tasks[] = [
4634
"id" => $id++,
@@ -56,11 +44,7 @@ $app->post("/add", (Request $request) => {
5644
$app->get("/remove/{id}", (Request $request, $id) => {
5745
$session = $request->getSession();
5846

59-
$tasks = $session->get("tasks");
60-
61-
if (!$tasks) {
62-
$tasks = [];
63-
}
47+
$tasks = $session->get("tasks", []);
6448

6549
$tasks = array_filter($tasks, ($task) => {
6650
return $task["id"] !== (int) $id;

0 commit comments

Comments
 (0)