forked from NEKOGET/FuelPHP_docs_jp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinflector.html
793 lines (767 loc) · 22.3 KB
/
inflector.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
<!doctype html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./../assets/css/combined.css">
<link rel="shortcut icon" href="./../favicon.ico" />
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">
var path = './../';
var class_prefix = "Inflector::";
</script>
<script src="./../assets/js/combined.js"></script>
<title>Inflector - クラス - FuelPHP ドキュメント</title>
</head>
<body>
<div id="container">
<header id="header">
<div class="table">
<h1>
<a href="http://fuelphp.com"><img height="37px" width="147px" src="./../assets/img/fuel.png" /></a>
<strong>Documentation</strong>
</h1>
<form id="google_search">
<p>
<span id="search_clear"> </span>
<input type="submit" name="search_submit" id="search_submit" value="検索" />
<input type="text" value="" id="search_input" name="search_input" />
</p>
</form>
</div>
<nav>
<div class="clear"></div>
</nav>
<a href="#" id="toc_handle">目次</a>
<div class="clear"></div>
</header>
<div id="cse">
<div id="cse_point"></div>
<div id="cse_content"></div>
</div>
<div id="main">
<h2>Inflector クラス</h2>
<p>
Inflector クラスでは単数形から複数形、クラス名からテーブル名、
モジュール化されたクラス名をなしに、そして、クラス名から外部キーに
単語を変換することができます。
</p>
<p>
ローカライズできるようにするために、インフレクタのルールセットを言語ファイルとして定義することが可能です。
フレームワークは英語のためのルールのデフォルトセットが付属しており、
それをローカライズのためのテンプレートとすることができます。
</p>
<article>
<h4 class="method" id="method_ascii">ascii($str, $allow_non_ascii = false)</h4>
<p><strong>ascii</strong> メソッドは文字列を 7-bit のアスキー文字に変換することができます。このメソッドは UTF-8 の環境のみで動作します。</p>
<table class="method">
<tbody>
<tr>
<th class="legend">静的</th>
<td>はい</td>
</tr>
<tr>
<th>パラメータ</th>
<td>
<table class="parameters">
<tr>
<th>パラメータ</th>
<th>デフォルト</th>
<th class="description">説明</th>
</tr>
<tr>
<th><kbd>$str</kbd></th>
<td><i>必須</i></td>
<td>変換したい文字列</td>
</tr>
<tr>
<th><kbd>$allow_non_ascii</kbd></th>
<td><pre class="php"><code>false</code></pre></td>
<td>非アスキー文字を許可するか</td>
</tr>
</table>
</td>
</tr>
<tr>
<th>返り値</th>
<td>string</td>
</tr>
<tr>
<th>例</th>
<td>
<pre class="php"><code>echo Inflector::ascii('Inglés'); // Ingles と返す</code></pre>
</td>
</tr>
</tbody>
</table>
</article>
<article>
<h4 class="method" id="method_camelize">camelize($underscored_word)</h4>
<p><strong>camelize</strong> メソッドはアンダースコアで区切られた単語をキャメルケースの単語に変換することができます。</p>
<table class="method">
<tbody>
<tr>
<th class="legend">静的</th>
<td>はい</td>
</tr>
<tr>
<th>パラメータ</th>
<td>
<table class="parameters">
<tr>
<th>パラメータ</th>
<th>デフォルト</th>
<th class="description">説明</th>
</tr>
<tr>
<th><kbd>$underscored_word</kbd></th>
<td><i>必須</i></td>
<td>アンダースコアで区切られた単語</td>
</tr>
</table>
</td>
</tr>
<tr>
<th>返り値</th>
<td>string</td>
</tr>
<tr>
<th>例</th>
<td>
<pre class="php"><code>echo Inflector::camelize('apples_and_oranges'); // ApplesAndOranges と返す</code></pre>
</td>
</tr>
</tbody>
</table>
</article>
<article>
<h4 class="method" id="method_words_to_upper">words_to_upper($class)</h4>
<p><strong>words_to_upper</strong> メソッドはアンダースコアで区切られたクラス名のような単語を
アンダースコアごとの最初の文字を大文字に変換することができます。</p>
<table class="method">
<tbody>
<tr>
<th class="legend">静的</th>
<td>はい</td>
</tr>
<tr>
<th>パラメータ</th>
<td>
<table class="parameters">
<tr>
<th>パラメータ</th>
<th>デフォルト</th>
<th class="description">説明</th>
</tr>
<tr>
<th><kbd>$class</kbd></th>
<td><i>必須</i></td>
<td>クラス名</td>
</tr>
<tr>
<th><kbd>$sep</kbd></th>
<td><i>_</i></td>
<td>区切り文字</td>
</tr>
</table>
</td>
</tr>
<tr>
<th>返り値</th>
<td>string</td>
</tr>
<tr>
<th>例</th>
<td>
<pre class="php"><code>echo Inflector::words_to_upper('fuel_users'); // Fuel_Users と返す
echo Inflector::words_to_upper('module::method', '::'); // Module::Method と返す</code></pre>
</td>
</tr>
</tbody>
</table>
</article>
<article>
<h4 class="method" id="method_classify">classify($table_name)</h4>
<p><strong>classify</strong> メソッドはテーブル名をクラス名に変換することができます。</p>
<table class="method">
<tbody>
<tr>
<th class="legend">静的</th>
<td>はい</td>
</tr>
<tr>
<th>パラメータ</th>
<td>
<table class="parameters">
<tr>
<th>パラメータ</th>
<th>デフォルト</th>
<th class="description">説明</th>
</tr>
<tr>
<th><kbd>$table_name</kbd></th>
<td><i>必須</i></td>
<td>テーブル名</td>
</tr>
<tr>
<th><kbd>$singularize</kbd></th>
<td><pre class="php"><code>true</code></pre></td>
<td>$tablename を大文字化する前に単数形に変換するか</td>
</tr>
</table>
</td>
</tr>
<tr>
<th>返り値</th>
<td>string</td>
</tr>
<tr>
<th>例</th>
<td>
<pre class="php"><code>echo Inflector::classify('fuel_users'); // Fuel_User と返す</code></pre>
</td>
</tr>
</tbody>
</table>
</article>
<article>
<h4 class="method" id="method_demodulize">demodulize($class_name_in_module)</h4>
<p><strong>demodulize</strong> メソッドはモジュール化された文字列からクラス名を取り除くことができます。</p>
<table class="method">
<tbody>
<tr>
<th class="legend">静的</th>
<td>はい</td>
</tr>
<tr>
<th>パラメータ</th>
<td>
<table class="parameters">
<tr>
<th>パラメータ</th>
<th>デフォルト</th>
<th class="description">説明</th>
</tr>
<tr>
<th><kbd>$class_name_in_module</kbd></th>
<td><i>必須</i></td>
<td>モジュール化されたクラス名</td>
</tr>
</table>
</td>
</tr>
<tr>
<th>返り値</th>
<td>string</td>
</tr>
<tr>
<th>例</th>
<td>
<pre class="php"><code>echo Inflector::demodulize('Uri::main()'); // main() と返す</code></pre>
</td>
</tr>
</tbody>
</table>
</article>
<article>
<h4 class="method" id="method_denamespace">denamespace($class_name)</h4>
<p><strong>denamespace</strong> メソッドはクラス名から名前空間を表す文字をを取り除くことができます。</p>
<table class="method">
<tbody>
<tr>
<th class="legend">静的</th>
<td>はい</td>
</tr>
<tr>
<th>パラメータ</th>
<td>
<table class="parameters">
<tr>
<th>パラメータ</th>
<th>デフォルト</th>
<th class="description">説明</th>
</tr>
<tr>
<th><kbd>$class_name</kbd></th>
<td><i>必須</i></td>
<td>クラス名</td>
</tr>
</table>
</td>
</tr>
<tr>
<th>返り値</th>
<td>string</td>
</tr>
<tr>
<th>例</th>
<td>
<pre class="php"><code>echo Inflector::denamespace('Fuel\\Core\\Config'); // Config と返す</code></pre>
</td>
</tr>
</tbody>
</table>
</article>
<article>
<h4 class="method" id="method_get_namespace">get_namespace($class_name)</h4>
<p><strong>get_namespace</strong> メソッドはクラス名から名前空間を表す文字を取り出すことができます。</p>
<table class="method">
<tbody>
<tr>
<th class="legend">静的</th>
<td>はい</td>
</tr>
<tr>
<th>パラメータ</th>
<td>
<table class="parameters">
<tr>
<th>パラメータ</th>
<th>デフォルト</th>
<th class="description">説明</th>
</tr>
<tr>
<th><kbd>$class_name</kbd></th>
<td><i>必須</i></td>
<td>クラス名</td>
</tr>
</table>
</td>
</tr>
<tr>
<th>返り値</th>
<td>string 、名前空間</td>
</tr>
<tr>
<th>例</th>
<td>
<pre class="php"><code>echo Inflector::get_namespace('Fuel\\Core\\Config'); // Fuel\Core\ と返す</code></pre>
</td>
</tr>
</tbody>
</table>
</article>
<article>
<h4 class="method" id="method_foreign_key">foreign_key($class_name, $use_underscore = true)</h4>
<p><strong>foreign_key</strong> メソッドはクラス名から外部キー名を返すことができます。</p>
<table class="method">
<tbody>
<tr>
<th class="legend">静的</th>
<td>はい</td>
</tr>
<tr>
<th>パラメータ</th>
<td>
<table class="parameters">
<tr>
<th>パラメータ</th>
<th>デフォルト</th>
<th class="description">説明</th>
</tr>
<tr>
<th><kbd>$class_name</kbd></th>
<td><i>必須</i></td>
<td>クラス名</td>
</tr>
<tr>
<th><kbd>$use_underscore</kbd></th>
<td><pre class="php"><code>true</code></pre></td>
<td>クラス名の後ろにアンダースコアをつけるか</td>
</tr>
</table>
</td>
</tr>
<tr>
<th>返り値</th>
<td>string</td>
</tr>
<tr>
<th>例</th>
<td>
<pre class="php"><code>echo Inflector::foreign_key('Inflector'); // inflector_id と返す
echo Inflector::foreign_key('Inflector', false); // inflectorid と返す</code></pre>
</td>
</tr>
</tbody>
</table>
</article>
<article>
<h4 class="method" id="method_friendly_title">friendly_title($str, $sep = '-', $lowercase = false, $allow_non_ascii = false)</h4>
<p><strong>friendly_title</strong> メソッドは文字列を URL に使えるようにタイトルを変換することができます。このメソッドは UTF-8 の文字コードを渡して、 7-bit アスキー文字で返します。</p>
<table class="method">
<tbody>
<tr>
<th class="legend">静的</th>
<td>はい</td>
</tr>
<tr>
<th>パラメータ</th>
<td>
<table class="parameters">
<tr>
<th>パラメータ</th>
<th>デフォルト</th>
<th class="description">説明</th>
</tr>
<tr>
<th><kbd>$str</kbd></th>
<td><i>必須</i></td>
<td>変換したい文字列</td>
</tr>
<tr>
<th><kbd>$sep</kbd></th>
<td><pre class="php"><code>-</code></pre></td>
<td>区切り文字 (- か _ のどちらか)</td>
</tr>
<tr>
<th><kbd>$lowercase</kbd></th>
<td><pre class="php"><code>false</code></pre></td>
<td>小文字だけにするか</td>
</tr>
<tr>
<th><kbd>$allow_non_ascii</kbd></th>
<td><pre class="php"><code>false</code></pre></td>
<td>非アスキー文字を許可するか</td>
</tr>
</table>
</td>
</tr>
<tr>
<th>返り値</th>
<td>string</td>
</tr>
<tr>
<th>例</th>
<td>
<pre class="php"><code>echo Inflector::friendly_title('Fuel is a community driven PHP 5 web framework.', '-', true);
// fuel-is-a-community-driven-php-5-web-framework と返す</code></pre>
</td>
</tr>
</tbody>
</table>
</article>
<article>
<h4 class="method" id="method_humanize">humanize($lower_case_and_underscored_word)</h4>
<p><strong>humanize</strong> メソッドはアンダースコアで区切られた単語を人間が読みやすいように変換することができます。</p>
<table class="method">
<tbody>
<tr>
<th class="legend">静的</th>
<td>はい</td>
</tr>
<tr>
<th>パラメータ</th>
<td>
<table class="parameters">
<tr>
<th>パラメータ</th>
<th>デフォルト</th>
<th class="description">説明</th>
</tr>
<tr>
<th><kbd>$lower_case_and_underscored_word</kbd></th>
<td><i>必須</i></td>
<td>変換したい単語</td>
</tr>
</table>
</td>
</tr>
<tr>
<th>返り値</th>
<td>string</td>
</tr>
<tr>
<th>例</th>
<td>
<pre class="php"><code>echo Inflector::humanize('apples_and_oranges'); // Apples and oranges と返す</code></pre>
</td>
</tr>
</tbody>
</table>
</article>
<article>
<h4 class="method" id="method_is_countable">is_countable($word)</h4>
<p><strong>is_countable</strong> メソッドは指定された単語に複数形の単語があるかどうかチェックすることができます。</p>
<table class="method">
<tbody>
<tr>
<th class="legend">静的</th>
<td>はい</td>
</tr>
<tr>
<th>パラメータ</th>
<td>
<table class="parameters">
<tr>
<th>パラメータ</th>
<th>デフォルト</th>
<th class="description">説明</th>
</tr>
<tr>
<th><kbd>$word</kbd></th>
<td><i>必須</i></td>
<td>チェックしたい単語</td>
</tr>
</table>
</td>
</tr>
<tr>
<th>返り値</th>
<td>boolean</td>
</tr>
<tr>
<th>例</th>
<td>
<pre class="php"><code>echo Inflector::is_countable('fish'); // false を返す
echo Inflector::is_countable('apple'); // true を返す</code></pre>
</td>
</tr>
</tbody>
</table>
</article>
<article>
<h4 class="method" id="method_pluralize">pluralize($word, $count)</h4>
<p><strong>pluralize</strong> メソッドは指定された単語を複数形に変換することができます。</p>
<table class="method">
<tbody>
<tr>
<th class="legend">静的</th>
<td>はい</td>
</tr>
<tr>
<th>パラメータ</th>
<td>
<table class="parameters">
<tr>
<th>パラメータ</th>
<th>デフォルト</th>
<th class="description">説明</th>
</tr>
<tr>
<th><kbd>$word</kbd></th>
<td><i>必須</i></td>
<td>複数形にしたい単語</td>
</tr>
<tr>
<th><kbd>$count</kbd></th>
<td><strong>0</strong></td>
<td>もし <kbd>1</kbd> を指定すると複数形ではなく、単数形の単語を返します</td>
</tr>
</table>
</td>
</tr>
<tr>
<th>返り値</th>
<td>string</td>
</tr>
<tr>
<th>例</th>
<td>
<pre class="php"><code>echo Inflector::pluralize('apple'); // apples と返す
echo Inflector::pluralize('apple', 1); // apple と返す</code></pre>
</td>
</tr>
</tbody>
</table>
</article>
<article>
<h4 class="method" id="method_ordinalize">ordinalize($number)</h4>
<p><strong>ordinalize</strong> メソッドは英語での順番を表す単語に変換することができます。</p>
<table class="method">
<tbody>
<tr>
<th class="legend">静的</th>
<td>はい</td>
</tr>
<tr>
<th>パラメータ</th>
<td>
<table class="parameters">
<tr>
<th>パラメータ</th>
<th>デフォルト</th>
<th class="description">説明</th>
</tr>
<tr>
<th><kbd>$number</kbd></th>
<td><i>必須</i></td>
<td>順番を表す単語をしりたい数字</td>
</tr>
</table>
</td>
</tr>
<tr>
<th>返り値</th>
<td>string</td>
</tr>
<tr>
<th>例</th>
<td>
<pre class="php"><code>echo Inflector::ordinalize(2); // 2nd と返す</code></pre>
</td>
</tr>
</tbody>
</table>
</article>
<article>
<h4 class="method" id="method_singularize">singularize($word)</h4>
<p><strong>singularize</strong> メソッドは指定された単語の単数形に変換することができます。</p>
<table class="method">
<tbody>
<tr>
<th class="legend">静的</th>
<td>はい</td>
</tr>
<tr>
<th>パラメータ</th>
<td>
<table class="parameters">
<tr>
<th>パラメータ</th>
<th>デフォルト</th>
<th class="description">説明</th>
</tr>
<tr>
<th><kbd>$word</kbd></th>
<td><i>必須</i></td>
<td>単数形にしたい単語</td>
</tr>
</table>
</td>
</tr>
<tr>
<th>返り値</th>
<td>string</td>
</tr>
<tr>
<th>例</th>
<td>
<pre class="php"><code>echo Inflector::singularize('apples'); // apple と返す</code></pre>
</td>
</tr>
</tbody>
</table>
</article>
<article>
<h4 class="method" id="method_tableize">tableize($class_name)</h4>
<p><strong>tableize</strong> メソッドはクラス名をテーブル名に変換することができます。</p>
<table class="method">
<tbody>
<tr>
<th class="legend">静的</th>
<td>はい</td>
</tr>
<tr>
<th>パラメータ</th>
<td>
<table class="parameters">
<tr>
<th>パラメータ</th>
<th>デフォルト</th>
<th class="description">説明</th>
</tr>
<tr>
<th><kbd>$class_name</kbd></th>
<td><i>必須</i></td>
<td>クラス名の文字列</td>
</tr>
</table>
</td>
</tr>
<tr>
<th>返り値</th>
<td>string</td>
</tr>
<tr>
<th>例</th>
<td>
<pre class="php"><code>echo Inflector::tableize('FuelUser'); // fuel_users と返す</code></pre>
</td>
</tr>
</tbody>
</table>
</article>
<article>
<h4 class="method" id="method_underscore">underscore($camel_cased_word)</h4>
<p><strong>underscore</strong> メソッドはキャメルケースの単語をアンダースコアで区切った単語に変換することができます。</p>
<table class="method">
<tbody>
<tr>
<th class="legend">静的</th>
<td>はい</td>
</tr>
<tr>
<th>パラメータ</th>
<td>
<table class="parameters">
<tr>
<th>パラメータ</th>
<th>デフォルト</th>
<th class="description">説明</th>
</tr>
<tr>
<th><kbd>$camel_cased_word</kbd></th>
<td><i>必須</i></td>
<td>キャメルケースの単語</td>
</tr>
</table>
</td>
</tr>
<tr>
<th>返り値</th>
<td>string</td>
</tr>
<tr>
<th>例</th>
<td>
<pre class="php"><code>echo Inflector::underscore('ApplesAndOranges'); // apples_and_oranges と返す</code></pre>
</td>
</tr>
</tbody>
</table>
</article>
<article>
<h4 class="method" id="method_load_rules">load_rules()</h4>
<p>
<strong>load_rules</strong> メソッドは現在の言語設定に基づいてインフレクタルールをロードします。
ルールセットが見つからない (すなわち全くインフレクタ言語ファイルが存在しない)
場合、クラスは英語のためのルールセットをデフォルトとします。 ルールセットを読み込み済みの場合は、
お使いの言語の設定を変更し、再読み込みします。しかし新しい設定がルールセットの定義を持っていない時は、
インフレクタは現在のものを利用し続けます。
</p>
<p class="note">
最初の Inflector クラス使用時には言語設定に基づいてルールセットが自動で読み込まれます。
通常はこのメソッドを使用する必要はありません。
</p>
<table class="method">
<tbody>
<tr>
<th class="legend">静的</th>
<td>はい</td>
</tr>
<tr>
<th>パラメータ</th>
<td>
なし
</td>
</tr>
<tr>
<th>例</th>
<td>
<pre class="php"><code>Inflector::load_rules(); // インフレクタルールセットを (再) 読み込み</code></pre>
</td>
</tr>
</tbody>
</table>
</article>
</div>
<footer>
<p>
© FuelPHP Development Team 2010-2016 - <a href="http://fuelphp.com">FuelPHP</a> is released under the MIT license.
[ <a href="https://github.com/fuel/docs/commits/1.8/develop/classes/inflector.html">原文コミット履歴</a> | <a href="https://github.com/NEKOGET/FuelPHP_docs_jp/commits/1.8/develop_japanese/classes/inflector.html">翻訳コミット履歴</a> | <a href="https://github.com/NEKOGET/FuelPHP_docs_jp/blob/1.8/develop_japanese/classes/inflector.html">GitHubで修正</a> ]
</p>
</footer>
</div>
</body>
</html>