Open
Conversation
Member
|
Thank you 🙂 I would like to suggest moving the check method to You could do something like class Sentence extends Entity
{
public function isCorrectLastCharacter() {
$sentence = $this->sentence;
$lang = $this->lang;
// do your thing...
}
}And then class SentenceTest extends TestCase
{
public function testIsCorrectLastCharacter() {
$entity = new Sentence(['lang' => 'eng', 'text' => 'Test this']);
$result = $entity->isCorrectLastCharacter();
$this->assertFalse($result);
}
}And later we can make it a model validation rule like this. |
Author
|
I didn't understand that part about the model validation rule, but that can be kept for later... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a start on issue #3264.
I thought it might be a good idea to add this one already, although it is not used yet. I plan to add some more of such functions (checking the first symbol, checking all symbols of a sentence, checking some typical mistakes like space before comma and so on). Eventually they can be used to implement the real check.
I changed the function a little bit compared to the function given in the issue: It now returns the offending character instead of false. This might be useful in warning messages.
I'm unsure if the place I've choosen (
Model/Table/SentenceTable) is a good place for these functions. If you prefere some other place, please just tell me.