core-bundle/src/OptIn/OptInToken.php
public function send(string $subject = null, string $text = null): void
    {
        if ($this->isConfirmed()) {
            throw new OptInTokenAlreadyConfirmedException();
        }

        if (!$this->isValid()) {
            throw new OptInTokenNoLongerValidException();
        }

        if (!$this->hasBeenSent()) {
            if (null === $subject || null === $text) {
                throw new \LogicException('Please provide subject and text to send the token');
            }

            $this->model->emailSubject = $subject;
            $this->model->emailText = $text;
            $this->model->save();
        }

        /** @var Email $email */
        $email = $this->framework->createInstance(Email::class);
        $email->subject = $this->model->emailSubject;
        $email->text = $this->model->emailText;
        $email->sendTo($this->model->email);
    }
public function send(string $subject = null, string $text = null): void
    {
        if ($this->isConfirmed()) {
            throw new OptInTokenAlreadyConfirmedException();
        }

        if (!$this->isValid()) {
            throw new OptInTokenNoLongerValidException();
        }

        if (!$this->hasBeenSent()) {
            if (null === $subject || null === $text) {
                throw new \LogicException('Please provide subject and text to send the token');
            }

            $this->model->emailSubject = $subject;
            $this->model->emailText = $text;
            $this->model->save();
        }

        /** @var Email $email */
        $email = $this->framework->createInstance(Email::class);
        $email->subject = $this->model->emailSubject;
        $email->text = $this->model->emailText;
        $email->sendTo($this->model->email);
    }
public function send ( string $ subject = null , string $ text = null ) : void { if ( $ this -> isConfirmed ( ) ) { throw new OptInTokenAlreadyConfirmedException ( ) ; } if ( ! $ this -> isValid ( ) ) { throw new OptInTokenNoLongerValidException ( ) ; } if ( ! $ this -> hasBeenSent ( ) ) { if ( null === $ subject || null === $ text ) { throw new \ LogicException ( 'Please provide subject and text to send the token' ) ; } $ this -> model -> emailSubject = $ subject ; $ this -> model -> emailText = $ text ; $ this -> model -> save ( ) ; } /** @var Email $email */ $ email = $ this -> framework -> createInstance ( Email :: class ) ; $ email -> subject = $ this -> model -> emailSubject ; $ email -> text = $ this -> model -> emailText ; $ email -> sendTo ( $ this -> model -> email ) ; }
{@inheritdoc}

@throws \LogicException
{ @inheritdoc }