Completed
Push — master ( d2d728...adeb1e )
by f
02:09
created

web/index.php (4 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
require dirname(dirname(__FILE__)).'/vendor/autoload.php';
3
use morphos\Russian\Cases;
4
use morphos\Russian\GeneralDeclension;
5
use morphos\Russian\GeographicalNamesDeclension;
6
7
$dec = new morphos\Russian\GeneralDeclension();
8
$plu = new morphos\Russian\Plurality();
9
?><html>
10
<head>
11
	<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
12
	<link rel="stylesheet" href="https://code.getmdl.io/1.3.0/material.indigo-pink.min.css">
13
	<script defer src="https://code.getmdl.io/1.3.0/material.min.js"></script>
14
	<title>Morphos Testing Script</title>
15
</head>
16
<body>
17
	<div class="mdl-tabs mdl-js-tabs mdl-js-ripple-effect">
18
		<div class="mdl-tabs__tab-bar">
19
	      <a href="#personal-names" class="mdl-tabs__tab is-active">Склонение имен собственных</a>
20
	      <a href="#geographical-names" class="mdl-tabs__tab">Склонение географических названий</a>
21
	      <a href="#nouns" class="mdl-tabs__tab">Склонение существительных</a>
22
		</div>
23
24
		<div class="mdl-tabs__panel" id="nouns">
25
			<div class="mdl-grid">
26
				<div class="mdl-cell mdl-cell--6-col" style="text-align: right;">
27
					<form method="post" action="#nouns">
28
						<table class="mdl-data-table mdl-js-data-table mdl-shadow--2dp" style="margin: 0 0 0 auto;">
29
							<tbody>
30
								<tr>
31
									<td class="mdl-data-table__cell--non-numeric">Введите имя существительное: <input name="noun" value="<?= isset($_POST['noun']) ? $_POST['noun'] : null ?>"></td>
32
								</tr>
33
								<tr>
34
									<td class="mdl-data-table__cell--non-numeric"><label><input type="checkbox" name="animate" <?= isset($_POST['animate']) ? "checked='checked'" : null ?> /> Одушевлённое</label></td>
35
								</tr>
36
								<tr>
37
									<td class="mdl-data-table__cell--non-numeric"><input type="submit"/></td>
38
								</tr>
39
							</tbody>
40
						</table>
41
					</form>
42
				</div>
43
				<div class="mdl-cell mdl-cell--6-col" style="text-align: left;">
44 View Code Duplication
<?php if (isset($_POST['noun'])): ?>
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
45
	<?php
46
	$cases = GeneralDeclension::getCases($_POST['noun']);
47
	?>
48
				<table class="mdl-data-table mdl-js-data-table mdl-shadow--2dp">
49
					<tbody>
50
						<tr>
51
							<td class="mdl-data-table__cell--non-numeric" colspan="2" style="text-align: center;"><?=$_POST['noun']?> (<?=GeneralDeclension::getDeclension($_POST['noun'])?> склонение)</td>
52
						</tr>
53
						<?php foreach(array(Cases::IMENIT => 'Именительный', Cases::RODIT => 'Родительный', Cases::DAT => 'Дательный', Cases::VINIT => 'Винительный', Cases::TVORIT => 'Творительный', Cases::PREDLOJ => 'Предложный') as $case => $name): ?>
54
							<tr>
55
								<td class="mdl-data-table__cell--non-numeric"><?=$name?></td>
56
								<td class="mdl-data-table__cell--non-numeric"><?=$cases[$case]?></td>
57
							</tr>
58
						<?php endforeach; ?>
59
					</tbody>
60
				</table>
61
<?php endif; ?>
62
				</div>
63
			</div>
64
		</form>
65
<?php
66
if (isset($_POST['word'])) {
67
	if (!isset($_POST['animate'])) $_POST['animate'] = false;
68
	else $_POST['animate'] = true;
69
70
	echo '<pre>';
71
		var_dump($dec->getDeclension($_POST['word']));
72
	echo '</pre>';
73
	echo '<pre>';
74
		var_dump($dec->getForms($_POST['word'], $_POST['animate']));
0 ignored issues
show
The method getForms() does not seem to exist on object<morphos\Russian\GeneralDeclension>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
75
	echo '</pre>';
76
	echo '<pre>';
77
		var_dump($plu->getForms($_POST['word'], $_POST['animate']));
0 ignored issues
show
The method getForms() does not seem to exist on object<morphos\Russian\Plurality>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
78
	echo '</pre>';
79
80
	echo "<blockquote>";
81
	for ($i = 0; $i <= 20; $i++) {
82
		echo $i.' '.$plu->pluralize($_POST['word'], $i, $_POST['animate'])."<br/>";
83
	}
84
	echo "</blockquote>";
85
}
86
?>
87
	</div>
88
89
	<div class="mdl-tabs__panel" id="geographical-names">
90
		<div class="mdl-grid">
91
			<div class="mdl-cell mdl-cell--6-col" style="text-align: right;">
92
				<form method="post" action="#geographical-names">
93
					<table class="mdl-data-table mdl-js-data-table mdl-shadow--2dp" style="margin: 0 0 0 auto;">
94
						<tbody>
95
							<tr>
96
								<td class="mdl-data-table__cell--non-numeric">Введите название города или улицы: <input name="geographical-name" value="<?= isset($_POST['geographical-name']) ? $_POST['geographical-name'] : null ?>"></td>
97
							</tr>
98
							<tr>
99
								<td class="mdl-data-table__cell--non-numeric">
100
									<input type="submit"/>
101
								</td>
102
							</tr>
103
						</tbody>
104
					</table>
105
				</form>
106
			</div>
107
			<div class="mdl-cell mdl-cell--6-col" style="text-align: left;">
108 View Code Duplication
			<?php if (isset($_POST['geographical-name'])): ?>
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
109
	<?php
110
	$cases = GeographicalNamesDeclension::getCases($_POST['geographical-name']);
111
	?>
112
				<table class="mdl-data-table mdl-js-data-table mdl-shadow--2dp">
113
					<tbody>
114
						<tr>
115
							<td class="mdl-data-table__cell--non-numeric" colspan="2" style="text-align: center;"><?=$_POST['geographical-name']?></td>
116
						</tr>
117
						<?php foreach(array(Cases::IMENIT => 'Именительный', Cases::RODIT => 'Родительный', Cases::DAT => 'Дательный', Cases::VINIT => 'Винительный', Cases::TVORIT => 'Творительный', Cases::PREDLOJ => 'Предложный') as $case => $name): ?>
118
							<tr>
119
								<td class="mdl-data-table__cell--non-numeric"><?=$name?></td>
120
								<td class="mdl-data-table__cell--non-numeric"><?=$cases[$case]?></td>
121
							</tr>
122
						<?php endforeach; ?>
123
					</tbody>
124
				</table>
125
<?php endif; ?>
126
			</div>
127
		</div>
128
	</div>
129
130
	<div class="mdl-tabs__panel is-active" id="personal-names">
131
		<div class="mdl-grid">
132
			<div class="mdl-cell mdl-cell--6-col" style="text-align: right;">
133
				<form method="post" action="#personal-names">
134
					<table class="mdl-data-table mdl-js-data-table mdl-shadow--2dp" style="margin: 0 0 0 auto;">
135
						<tbody>
136
							<tr>
137
								<td class="mdl-data-table__cell--non-numeric">Введите Имя: <input name="name" value="<?= isset($_POST['name']) ? $_POST['name'] : null ?>"></td>
138
							</tr>
139
							<tr>
140
								<td class="mdl-data-table__cell--non-numeric">
141
									Выберите пол:
142
									<label><input type="radio" name="gender" value="" <?= isset($_POST['gender']) && $_POST['gender'] == '' ? "checked='checked'" : null ?> /> Автоматически </label>
143
									<label><input type="radio" name="gender" value="<?=morphos\Gender::MALE?>" <?= isset($_POST['gender']) && $_POST['gender'] == morphos\Gender::MALE ? "checked='checked'" : null ?> /> Мужской </label>
144
									<label><input type="radio" name="gender" value="<?=morphos\Gender::FEMALE?>" <?= isset($_POST['gender']) && $_POST['gender'] == morphos\Gender::FEMALE ? "checked='checked'" : null ?> /> Женский </label>
145
								</td>
146
							</tr>
147
							<tr>
148
								<td class="mdl-data-table__cell--non-numeric">
149
									<input type="submit"/>
150
								</td>
151
							</tr>
152
						</tbody>
153
					</table>
154
				</form>
155
			</div>
156
			<div class="mdl-cell mdl-cell--6-col" style="text-align: left;">
157
<?php if (isset($_POST['name'])): ?>
158
	<?php
159
	$gender = !empty($_POST['gender']) ? $_POST['gender'] : morphos\Russian\detectGender($_POST['name']);
160
	$cases = morphos\Russian\name($_POST['name'], null, $gender);
161
	?>
162
				<table class="mdl-data-table mdl-js-data-table mdl-shadow--2dp">
163
					<tbody>
164
						<tr>
165
							<td class="mdl-data-table__cell--non-numeric" colspan="2" style="text-align: center;"><?=$_POST['name']?> (<?=$gender?>)</td>
166
						</tr>
167
						<?php foreach(array(Cases::IMENIT => 'Именительный', Cases::RODIT => 'Родительный', Cases::DAT => 'Дательный', Cases::VINIT => 'Винительный', Cases::TVORIT => 'Творительный', Cases::PREDLOJ => 'Предложный') as $case => $name): ?>
168
							<tr>
169
								<td class="mdl-data-table__cell--non-numeric"><?=$name?></td>
170
								<td class="mdl-data-table__cell--non-numeric"><?=$cases[$case]?></td>
171
							</tr>
172
						<?php endforeach; ?>
173
					</tbody>
174
				</table>
175
<?php endif; ?>
176
			</div>
177
		</div>
178
	</div>
179
</body>
180
</html>