Skip to content

Commit 5955727

Browse files
committed
Remove redundant code and comments.
1 parent 639190f commit 5955727

File tree

7 files changed

+6
-154
lines changed

7 files changed

+6
-154
lines changed

src/Entity/Box.php

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,6 @@ final class Box
6464
private $tag;
6565

6666

67-
/**
68-
* @param string $type
69-
* @param string|null $title
70-
* @param string|null $text
71-
* @param string|null $url
72-
* @param int $rank
73-
*/
7467
public function __construct(string $type = self::TYPE_UNDEFINED, ?string $title = null, ?string $text = null, ?string $url = null, int $rank = 32)
7568
{
7669
$this->type = $type;
@@ -81,9 +74,6 @@ public function __construct(string $type = self::TYPE_UNDEFINED, ?string $title
8174
}
8275

8376

84-
/**
85-
* @return string
86-
*/
8777
public function __toString(): string
8878
{
8979
return $this->type === self::TYPE_TEXT
@@ -113,7 +103,6 @@ public function setKeyValue(array $table = []): self
113103
{
114104
if ($table !== []) {
115105
$items = [];
116-
117106
foreach ($table as $key => $value) {
118107
$items[] = '<tr>'
119108
. '<th' . ($items === [] ? ' style="width:33%"' : '') . '>'
@@ -130,9 +119,6 @@ public function setKeyValue(array $table = []): self
130119
}
131120

132121

133-
/**
134-
* @return string
135-
*/
136122
public function getIcon(): string
137123
{
138124
if ($this->icon === null) {
@@ -145,10 +131,6 @@ public function getIcon(): string
145131
}
146132

147133

148-
/**
149-
* @param string $icon
150-
* @return Box
151-
*/
152134
public function setIcon(string $icon): self
153135
{
154136
if (preg_match('/^(fas?)\s+(fa-[a-z0-9\-]+)$/', Strings::normalize($icon), $parser)) {
@@ -161,19 +143,12 @@ public function setIcon(string $icon): self
161143
}
162144

163145

164-
/**
165-
* @return string
166-
*/
167146
public function getTitle(): string
168147
{
169148
return $this->title ?? '';
170149
}
171150

172151

173-
/**
174-
* @param string $title
175-
* @return Box
176-
*/
177152
public function setTitle(string $title): self
178153
{
179154
$this->title = $title;
@@ -182,9 +157,6 @@ public function setTitle(string $title): self
182157
}
183158

184159

185-
/**
186-
* @return string
187-
*/
188160
public function getText(): string
189161
{
190162
return $this->text ?? '';
@@ -203,28 +175,18 @@ public function setText($text): self
203175
}
204176

205177

206-
/**
207-
* @return string|null
208-
*/
209178
public function getUrl(): ?string
210179
{
211180
return $this->url;
212181
}
213182

214183

215-
/**
216-
* @return int
217-
*/
218184
public function getRank(): int
219185
{
220186
return $this->rank;
221187
}
222188

223189

224-
/**
225-
* @param int $rank
226-
* @return Box
227-
*/
228190
public function setRank(int $rank): self
229191
{
230192
$this->rank = $rank;
@@ -240,7 +202,6 @@ public function setRank(int $rank): self
240202

241203

242204
/**
243-
* @return string|null
244205
* @internal
245206
*/
246207
public function getTag(): ?string
@@ -250,8 +211,6 @@ public function getTag(): ?string
250211

251212

252213
/**
253-
* @param string|null $tag
254-
* @return Box
255214
* @internal
256215
*/
257216
public function setTag(?string $tag): self
@@ -281,7 +240,6 @@ public function getSteps(): array
281240
public function setSteps(array $steps): self
282241
{
283242
$return = [];
284-
285243
foreach ($steps as $step) {
286244
if (!$step instanceof Step) {
287245
throw new InvalidArgumentException('Step must be instance of "' . Step::class . '".');
@@ -298,10 +256,6 @@ public function setSteps(array $steps): self
298256
}
299257

300258

301-
/**
302-
* @param Step $step
303-
* @return Box
304-
*/
305259
public function addStep(Step $step): self
306260
{
307261
$this->steps[] = $step;
@@ -310,9 +264,6 @@ public function addStep(Step $step): self
310264
}
311265

312266

313-
/**
314-
* @return string
315-
*/
316267
public function getType(): string
317268
{
318269
return $this->type;

src/Entity/Context.php

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,11 @@
55
namespace Mathematicator\Engine\Entity;
66

77

8-
use function count;
98
use Mathematicator\Engine\Exception\TerminateException;
109
use Mathematicator\Engine\Helpers;
11-
use Nette\SmartObject;
1210

1311
final class Context
1412
{
15-
use SmartObject;
16-
1713
public const BOXES_LIMIT = 100;
1814

1915
/** @var string */
@@ -35,42 +31,31 @@ final class Context
3531
private $interpret;
3632

3733

38-
/**
39-
* @param Query $query
40-
*/
4134
public function __construct(Query $query)
4235
{
4336
$this->query = $query->getQuery();
4437
$this->queryEntity = $query;
4538
}
4639

4740

48-
/**
49-
* @return string
50-
*/
5141
public function getQuery(): string
5242
{
5343
return $this->query;
5444
}
5545

5646

57-
/**
58-
* @return Query
59-
*/
6047
public function getQueryEntity(): Query
6148
{
6249
return $this->queryEntity;
6350
}
6451

6552

6653
/**
67-
* @param string $type
68-
* @return Box
6954
* @throws TerminateException
7055
*/
7156
public function addBox(string $type): Box
7257
{
73-
if (count($this->boxes) >= self::BOXES_LIMIT) {
58+
if (\count($this->boxes) >= self::BOXES_LIMIT) {
7459
throw new TerminateException(__METHOD__);
7560
}
7661

@@ -107,40 +92,25 @@ public function resetBoxes(): void
10792
}
10893

10994

110-
/**
111-
* @return Box|null
112-
*/
11395
public function getInterpret(): ?Box
11496
{
11597
return $this->interpret;
11698
}
11799

118100

119-
/**
120-
* @param string $boxType
121-
* @param string|null $content
122-
* @return Box
123-
*/
124101
public function setInterpret(string $boxType, ?string $content = null): Box
125102
{
126103
return $this->interpret = (new Box($boxType, 'Interpretace zadání dotazu', $content))
127104
->setIcon('fas fa-project-diagram');
128105
}
129106

130107

131-
/**
132-
* @param Source $source
133-
*/
134108
public function addSource(Source $source): void
135109
{
136110
$this->sources[] = $source;
137111
}
138112

139113

140-
/**
141-
* @param string $key
142-
* @return DynamicConfiguration
143-
*/
144114
public function getDynamicConfiguration(string $key): DynamicConfiguration
145115
{
146116
if (isset($this->dynamicConfigurations[$key]) === false) {
@@ -163,9 +133,6 @@ public function getDynamicConfigurations(): array
163133
/**
164134
* Generate absolute URL to result page by given query.
165135
* Route is defined by internal convention, in future it can be changed.
166-
*
167-
* @param string $query
168-
* @return string
169136
*/
170137
public function link(string $query): string
171138
{

src/Entity/DynamicConfiguration.php

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -27,37 +27,24 @@ final class DynamicConfiguration
2727
private $labels = [];
2828

2929

30-
/**
31-
* @param string $key
32-
*/
3330
public function __construct(string $key)
3431
{
3532
$this->key = $key;
3633
}
3734

3835

39-
/**
40-
* @return string
41-
*/
4236
public function getKey(): string
4337
{
4438
return $this->key;
4539
}
4640

4741

48-
/**
49-
* @return string|null
50-
*/
5142
public function getTitle(): ?string
5243
{
5344
return $this->title;
5445
}
5546

5647

57-
/**
58-
* @param string|null $title
59-
* @return DynamicConfiguration
60-
*/
6148
public function setTitle(?string $title): self
6249
{
6350
$this->title = $title;
@@ -66,13 +53,9 @@ public function setTitle(?string $title): self
6653
}
6754

6855

69-
/**
70-
* @return string
71-
*/
7256
public function getSerialized(): string
7357
{
7458
$return = '';
75-
7659
foreach ($this->data as $key => $value) {
7760
if (($value = trim((string) $value)) !== '') {
7861
$return .= ($return ? '&' : '') . urlencode($key) . '=' . urlencode($value);
@@ -83,11 +66,6 @@ public function getSerialized(): string
8366
}
8467

8568

86-
/**
87-
* @param string $key
88-
* @param string|null $default
89-
* @return string|null
90-
*/
9169
public function getValue(string $key, ?string $default = null): ?string
9270
{
9371
$this->defaults[$key] = $default;
@@ -102,7 +80,6 @@ public function getValue(string $key, ?string $default = null): ?string
10280
public function getValues(): array
10381
{
10482
$return = $this->data;
105-
10683
foreach ($this->defaults as $key => $value) {
10784
if ($value !== null || isset($this->data[$key]) === false) {
10885
$return[$key] = $value;
@@ -122,27 +99,17 @@ public function getLabels(): array
12299
}
123100

124101

125-
/**
126-
* @param string $key
127-
* @return string
128-
*/
129102
public function getLabel(string $key): string
130103
{
131104
return $this->labels[$key] ?? $key;
132105
}
133106

134107

135-
/**
136-
* @param string $key
137-
* @param string|null $label
138-
* @return DynamicConfiguration
139-
*/
140108
public function addLabel(string $key, ?string $label): self
141109
{
142110
if ($label === null && isset($this->labels[$key])) {
143111
unset($this->labels[$key]);
144112
}
145-
146113
if ($label !== null) {
147114
$this->labels[$key] = $label;
148115
}
@@ -153,7 +120,7 @@ public function addLabel(string $key, ?string $label): self
153120

154121
/**
155122
* @param string[]|null[] $haystack
156-
* @return DynamicConfiguration
123+
* @return self
157124
*/
158125
public function setValues(array $haystack): self
159126
{
@@ -167,11 +134,6 @@ public function setValues(array $haystack): self
167134
}
168135

169136

170-
/**
171-
* @param string $key
172-
* @param string|null $value
173-
* @return DynamicConfiguration
174-
*/
175137
public function setValue(string $key, ?string $value = null): self
176138
{
177139
$this->data[$key] = $value;

0 commit comments

Comments
 (0)