| Conditions | 4 |
| Paths | 8 |
| Total Lines | 33 |
| Code Lines | 26 |
| Lines | 16 |
| Ratio | 48.48 % |
| Tests | 0 |
| CRAP Score | 20 |
| 1 | <?php |
||
| 26 | public function requireDefaultRecords() { |
||
| 27 | parent::requireDefaultRecords(); |
||
| 28 | |||
| 29 | $similar = AutoCompleteOption::get()->filter('Name', 'Similar')->first(); |
||
| 30 | if (!$similar) { |
||
| 31 | $similar = new AutoCompleteOption(); |
||
| 32 | $similar->Name = 'Similar'; |
||
| 33 | $similar->Slug = 'SIMILAR'; |
||
| 34 | $similar->Description = 'Find records similar to the selected item'; |
||
|
|
|||
| 35 | $similar->Locale = i18n::default_locale(); |
||
| 36 | $similar->write(); |
||
| 37 | } |
||
| 38 | |||
| 39 | $search = AutoCompleteOption::get()->filter('Name', 'Search')->first(); |
||
| 40 | View Code Duplication | if (!$search) { |
|
| 41 | $search = new AutoCompleteOption(); |
||
| 42 | $search->Name = 'Search'; |
||
| 43 | $search->Description = 'Find records similar to the selected item'; |
||
| 44 | $search->Slug = 'SEARCH'; |
||
| 45 | $search->Locale = i18n::default_locale(); |
||
| 46 | $search->write(); |
||
| 47 | } |
||
| 48 | |||
| 49 | $goto = AutoCompleteOption::get()->filter('Name', 'GoToRecord')->first(); |
||
| 50 | View Code Duplication | if (!$goto) { |
|
| 51 | $goto = new AutoCompleteOption(); |
||
| 52 | $goto->Name = 'GoToRecord'; |
||
| 53 | $goto->Description = 'Go to the page of the selected item, found by the Link() method'; |
||
| 54 | $goto->Locale = i18n::default_locale(); |
||
| 55 | $goto->Slug = 'GOTO'; |
||
| 56 | $goto->write(); |
||
| 57 | } |
||
| 58 | } |
||
| 59 | } |
||
| 60 |
Since your code implements the magic setter
_set, this function will be called for any write access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.