Skip to content

Add function isCorrectLastCharacter#3265

Open
kumakyoo42 wants to merge 1 commit intoTatoeba:devfrom
kumakyoo42:issue-3264
Open

Add function isCorrectLastCharacter#3265
kumakyoo42 wants to merge 1 commit intoTatoeba:devfrom
kumakyoo42:issue-3264

Conversation

@kumakyoo42
Copy link

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.

@jiru
Copy link
Member

jiru commented Mar 11, 2026

Thank you 🙂

I would like to suggest moving the check method to src/Model/Entity/Sentence.php.

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.

@kumakyoo42
Copy link
Author

I didn't understand that part about the model validation rule, but that can be kept for later...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants