Skip to content

Commit 5b0a17c

Browse files
committed
feat: return self for most methods
1 parent a7610c3 commit 5b0a17c

File tree

6 files changed

+58
-20
lines changed

6 files changed

+58
-20
lines changed

src/NotFound/Layout/Elements/LayoutBar.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,31 @@ public function noBackground(): self
2323
return $this;
2424
}
2525

26-
public function addBarButton(LayoutBarButton $btn)
26+
public function addBarButton(LayoutBarButton $btn): self
2727
{
2828
$this->items->add($btn->build());
29+
30+
return $this;
2931
}
3032

31-
public function addPager(LayoutPager $pager)
33+
public function addPager(LayoutPager $pager): self
3234
{
3335
$this->items->add($pager->build());
36+
37+
return $this;
3438
}
3539

36-
public function addSearchBox(LayoutSearchBox $searchBox)
40+
public function addSearchBox(LayoutSearchBox $searchBox): self
3741
{
3842
$this->items->add($searchBox->build());
43+
44+
return $this;
3945
}
4046

41-
public function addText(LayoutText $text)
47+
public function addText(LayoutText $text): self
4248
{
4349
$this->items->add($text->build());
50+
51+
return $this;
4452
}
4553
}

src/NotFound/Layout/Elements/LayoutBreadcrumb.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ public function __construct()
2121
*
2222
* @return void
2323
*/
24-
public function addHome(string $title = null, string $link = '/')
24+
public function addHome(string $title = null, string $link = '/'): self
2525
{
2626
$this->properties->items[] = (object) ['title' => $title ?? 'Home', 'link' => $link];
27+
28+
return $this;
2729
}
2830

2931
/**
@@ -33,8 +35,10 @@ public function addHome(string $title = null, string $link = '/')
3335
* @param mixed $link Link (optional) Last item should always be the current path en should not link anywhere.
3436
* @return void
3537
*/
36-
public function addItem(string $title, string $link = null)
38+
public function addItem(string $title, string $link = null): self
3739
{
3840
$this->properties->items[] = (object) ['title' => $title, 'link' => $link];
41+
42+
return $this;
3943
}
4044
}

src/NotFound/Layout/Elements/LayoutForm.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,36 +18,48 @@ public function __construct(string $url)
1818
$this->properties->method = LayoutRequestMethod::POST;
1919
}
2020

21-
public function setMethod(LayoutRequestMethod $method)
21+
public function setMethod(LayoutRequestMethod $method): self
2222
{
2323
$this->properties->method = $method;
24+
25+
return $this;
2426
}
2527

26-
public function addButton(LayoutButton $btn)
28+
public function addButton(LayoutButton $btn): self
2729
{
2830
$this->items->add($btn->build());
31+
32+
return $this;
2933
}
3034

31-
public function addText(LayoutText $text)
35+
public function addText(LayoutText $text): self
3236
{
3337
$this->items->add($text->build());
38+
39+
return $this;
3440
}
3541

36-
public function addInput(AbstractInput $input): void
42+
public function addInput(AbstractInput $input): self
3743
{
3844
$this->items->add($input->build());
45+
46+
return $this;
3947
}
4048

41-
public function addTitle(LayoutTitle $title)
49+
public function addTitle(LayoutTitle $title): self
4250
{
4351
$title->setSize(4);
4452
$title->setUnderline();
4553
$this->items->add($title->build());
54+
55+
return $this;
4656
}
4757

4858
// TODO: think of better solution some time
49-
public function addComponent($component): void
59+
public function addComponent($component): self
5060
{
5161
$this->items->add($component->buildAutoLayoutClass());
62+
63+
return $this;
5264
}
5365
}

src/NotFound/Layout/Elements/LayoutPage.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,39 @@ public function __construct(string $title)
1818
$this->properties->title = $title;
1919
}
2020

21-
public function addWidget(LayoutWidget $widget)
21+
public function addWidget(LayoutWidget $widget): self
2222
{
2323
$this->items->add($widget->build());
24+
25+
return $this;
2426
}
2527

26-
public function addBreadCrumb(LayoutBreadcrumb $breadcrumb)
28+
public function addBreadCrumb(LayoutBreadcrumb $breadcrumb): self
2729
{
2830
$this->items->add($breadcrumb->build());
31+
32+
return $this;
2933
}
3034

31-
public function addTitle(LayoutTitle $title)
35+
public function addTitle(LayoutTitle $title): self
3236
{
3337
$this->items->add($title->build());
38+
39+
return $this;
3440
}
3541

36-
public function addBar(LayoutBar $bar)
42+
public function addBar(LayoutBar $bar): self
3743
{
3844
$this->items->add($bar->build());
45+
46+
return $this;
3947
}
4048

41-
public function addTabs(LayoutTabs $tabs)
49+
public function addTabs(LayoutTabs $tabs): self
4250
{
4351
$this->items->add($tabs->build());
52+
53+
return $this;
4454
}
4555

4656
public function build(): object

src/NotFound/Layout/Elements/LayoutTabs.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ public function __construct()
1010
$this->properties->padding = false;
1111
}
1212

13-
public function addPadding()
13+
public function addPadding(): self
1414
{
1515
$this->properties->padding = true;
16+
17+
return $this;
1618
}
1719

18-
public function addTab(LayoutTab $tab)
20+
public function addTab(LayoutTab $tab): self
1921
{
2022
$this->items->add($tab->build());
2123

src/NotFound/Layout/Helpers/LayoutWidgetHelper.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ public function response(): object
4646
* @param mixed $title
4747
* @param mixed $url
4848
*/
49-
public function addBreadcrumb($title, $url = null): void
49+
public function addBreadcrumb($title, $url = null): self
5050
{
5151
$this->breadcrumb->addItem($title, $url);
52+
53+
return $this;
5254
}
5355
}

0 commit comments

Comments
 (0)