Returns an array with true/false and an appropriate message when doing the email verification
@return array
@throws \InvalidArgumentException
765313
public function isValid()
    {
        $status = $this->response->body['result'];
        $reason = $this->response->body['reason'];

        switch($status):
            case 'valid':
                return [true, $this->getReason($reason)];
                break;
            case 'invalid':
            case 'unknown':
                return [false, $this->getReason($reason)];
                break;
            default:
                throw new InvalidArgumentException('Invalid Response');
        endSwitch;
    }

    /**
     * Get the reason whether the email is valid, invalid or unknown
     * @param  string $reason
     * @return string
     */
    public function getReason($reason)
    {
        return $this->serverResponses[$reason];
    }

    /**
     * Returns true or false if the email address uses a disposable domain
     * @return boolean
     */
    public function isDisposable()
    {
        return $this->response->body['disposable'];
    }

    /**
     * Returns true or false if the API request was successful
     * @return boolean
     */
    public function apiRequestStatus()
    {
        return $this->response->body['success'];
    }

    /**
     * Get the domain of the provided email address
     * @return string
     */
    public function getDomainName()
    {
        return $this->response->body['domain'];
    }

    /**
     * Get the local part of an email address
     * Example: prosperotemuyiwa@gmail.com returns prosperotemuyiwa
     * @return string
     */
    public function getUser()
    {
        return $this->response->body['user'];
    }

    /**
     * Gets a normalized version of the email address
     * Example: ProsperOtemuyiwa@gmail.com returns prosperotemuyiwa@gmail.com
     * @return string
     */
    public function getEmailAddress()
    {
        return $this->response->body['email'];
    }

    /**
     * Returns true if the domain appears to accept all emails delivered to that domain
     * @return boolean
     */
    public function acceptEmailsDeliveredToDomain()
    {
        return $this->response->body['accept_all'];
    }

    /**
     * Returns true or false if email address is a role address
     * Example manager@example.com , ceo@example.com will return true
     * @return boolean
     */
    public function isRole()
    {
        return $this->response->body['role'];
    }
}
946023
public function defaultArguments()
    {
        $arguments = [
            'email' => [
                'prefix'        => 'e',
                'longPrefix'    => 'email',
                'description'   => 'The user email'
            ],
            'password' => [
                'prefix'        => 'p',
                'longPrefix'    => 'password',
                'description'   => 'The user password',
                'inputType'     => 'password'
            ],
            'sendEmail' => [
                'longPrefix'    => 'send-email',
                'description'   => 'If set, an email will be sent to the user.',
                'noValue'       => true,
                'defaultValue'  => false
            ]
        ];

        $arguments = array_merge(parent::defaultArguments(), $arguments);

        return $arguments;
    }
1070836
public function verifyEmail()
  {
    if (Get::has('token')) {
      $provider = $this->provider;

      $verified = $this->verify(Get::key('token'), $provider, $this->musk());

      if (isset($verified->id)) {
        if (Session::has('_uas') && Session::key('_uas') == $verified->remember_token) {
          return $this->onSuccessfulEmailVerification(false);
        } else if (Auth::provider($provider)->login($verified)->status == 'success') {
          return $this->onSuccessfulEmailVerification(false);
        }
      }
    }

    $this->onSuccessfulEmailVerification(true);
  }
392551
public function toOptionArray()
    {
        return [
            [
                'value' => \Dotdigitalgroup\Email\Model\Sync\Catalog\CatalogSyncFactory::SYNC_CATALOG_DEFAULT_LEVEL,
                'label' => 'Default Level',
            ],
            [
                'value' => \Dotdigitalgroup\Email\Model\Sync\Catalog\CatalogSyncFactory::SYNC_CATALOG_STORE_LEVEL,
                'label' => 'Store Level',
            ],
        ];
    }
315330
protected function SendWishlistDataValid()
    {
        $bIsValid = true;
        $aRequiredFields = array('to_name', 'to_mail', 'comment');
        $oMsgManager = TCMSMessageManager::GetInstance();
        foreach ($aRequiredFields as $sFieldName) {
            if (!array_key_exists($sFieldName, $this->aUserInput)) {
                $this->aUserInput[$sFieldName] = '';
            } else {
                $this->aUserInput[$sFieldName] = trim($this->aUserInput[$sFieldName]);
            }
            if (empty($this->aUserInput[$sFieldName])) {
                $bIsValid = false;
                $oMsgManager->AddMessage(self::MSG_CONSUMER_NAME.'-'.$sFieldName, 'ERROR-USER-REQUIRED-FIELD-MISSING');
            }
        }

        return $bIsValid;
    }
313843
public function toArray(): array
    {
        return [
            'name' => $this->name,
            'text' => $this->text,
            'type' => $this->type,
            'value' => $this->value,
            'style' => $this->style,
            'confirm' => $this->confirmation,
        ];
    }
819966
public function confirm()
    {
        Yii::$app->get('hiart')->disableAuth();
        try {
            $confirmation = Contact::perform('confirm-email', [
                'confirm_data' => Yii::$app->request->get(),
            ]);

            return [
                'success' => true,
            ];
        } catch (\hiqdev\hiart\ResponseErrorException $e) {
            return [
                'success' => false,
                'message' => $e->getMessage(),
            ];
        }
    }
1052268
public function getDetailMessages()
    {
        $messages = array();
        foreach ($this->invalidRules as $field => $rules) {
            foreach ($rules as $rule) {
                $messages[$field][$rule] = $this->ruleValidators[$field][$rule]->getMessages();
            }
        }
        return $messages;
    }
1142144
protected function getArguments(): array
    {
        Factory::helper('string');
        $aArguments = [];

        if (!empty($this->aArguments)) {
            foreach ($this->aArguments as $aArgument) {
                $aArguments[] = (object) [
                    'name'     => getFromArray('name', $aArgument),
                    'value'    => $this->oInput->getArgument(getFromArray('name', $aArgument)),
                    'required' => getFromArray('required', $aArgument),
                ];
            }
        } else {
            $aArgumentsRaw = array_slice($this->oInput->getArguments(), 1);
            foreach ($aArgumentsRaw as $sField => $sValue) {
                $sField       = strtoupper(camelcase_to_underscore($sField));
                $aArguments[] = (object) [
                    'name'     => $sField,
                    'value'    => $sValue,
                    'required' => true,
                ];
            }
        }

        unset($sField);
        unset($sValue);

        foreach ($aArguments as &$oArgument) {
            if (empty($oArgument->value)) {
                $sLabel = str_replace('_', ' ', $oArgument->name);
                $sLabel = ucwords(strtolower($sLabel));
                $sError = '';
                do {
                    $oArgument->value = $this->ask($sError . $sLabel . ':', '');
                    $sError           = '<error>Please specify</error> ';
                    if ($oArgument->required && empty($oArgument->value)) {
                        $bAskAgain = true;
                    } else {
                        $bAskAgain = false;
                    }
                } while ($bAskAgain);
            }
        }
        unset($oArgument);

        //  Finally set as key values
        $aOut = [];
        foreach ($aArguments as $oArgument) {
            $aOut[strtoupper($oArgument->name)] = $oArgument->value;
        }

        return $aOut;
    }
515762
public function confirmEmailAction()
    {
        $code = $this->dispatcher->getParam('code');

        $confirmation = EmailConfirmations::findFirstByCode($code);

        if (!$confirmation) {
            return $this->dispatcher->forward([
                'controller' => 'index',
                'action' => 'index'
            ]);
        }

        if ($confirmation->confirmed != 'N') {
            return $this->dispatcher->forward([
                'controller' => 'session',
                'action' => 'login'
            ]);
        }

        $confirmation->confirmed = 'Y';

        $confirmation->user->active = 'Y';

        /**
         * Change the confirmation to 'confirmed' and update the user to 'active'
         */
        if (!$confirmation->save()) {

            foreach ($confirmation->getMessages() as $message) {
                $this->flash->error($message);
            }

            return $this->dispatcher->forward([
                'controller' => 'index',
                'action' => 'index'
            ]);
        }

        /**
         * Identify the user in the application
         */
        $this->auth->authUserById($confirmation->user->id);

        /**
         * Check if the user must change his/her password
         */
        if ($confirmation->user->mustChangePassword == 'Y') {

            $this->flash->success('The email was successfully confirmed. Now you must change your password');

            return $this->dispatcher->forward([
                'controller' => 'users',
                'action' => 'changePassword'
            ]);
        }

        $this->flash->success('The email was successfully confirmed');

        return $this->dispatcher->forward([
            'controller' => 'users',
            'action' => 'index'
        ]);
    }
1004356
public function valid()
    {
        if (! $this->messages) {
            $this->passes();
        }

        return array_diff_key(
            $this->data, $this->attributesThatHaveMessages()
        );
    }
1332689
public function message()
    {
        $messages = [];
        foreach($this->values as $key => $value) {
            if ($value->fails()) {
                $messages[$key] = $value->message();
            }
        }
        return $messages;
    }
1129235
public function getMessages(): array
    {
        $templates = [
            new Message($this->message->getBody(), $this->message->getContentType()),
        ];

        // TODO: Loop through parts

        return $templates;
    }
1375066
public function validate($message): array
    {
        if (\is_array($message)) {
            $message = CloudMessage::fromArray($message);
        }

        if (!($message instanceof Message)) {
            throw new InvalidArgumentException(
                'Unsupported message type. Use an array or a class implementing %s'.Message::class
            );
        }

        try {
            $response = $this->messagingApi->validateMessage($message);
        } catch (NotFound $e) {
            throw (new InvalidMessage($e->getMessage(), $e->getCode()))
                ->withResponse($e->response());
        }

        return JSON::decode((string) $response->getBody(), true);
    }
414324
public function is_valid() {
        $ret = false;

        if (is_null($this->deleteInsteadOfAppend) === false && is_null($this->subscriberIds) === false &&
            is_null($this->emails) === false
        ) {
            $ret = true;
        }

        return $ret;
    }
738012
public function toArray()
	{
		return [
			'name' => (string) $this->name,
			'email' => SerializationHelper::serialize($this->email),
			'links' => SerializationHelper::serialize($this->links)
		];
	}
417644
protected function getArguments()
    {
        return array(
            array('name', InputArgument::REQUIRED, false),
            array('type', InputArgument::OPTIONAL, false),
            array('folder', InputArgument::OPTIONAL, false),
        );
    }