/**
  * Remove a alias for the user (aliases.delete)
  *
  * @param string $userKey  The email or immutable Id of the user
  * @param string $alias  The alias to be removed
  * @return true|null depending on if an alias was deleted
  * @throws \Exception with code 201407101645
  */
 public function delete($userKey, $alias)
 {
     // If the $userKey is not an email address, it must be an id
     $key = 'primaryEmail';
     if (!filter_var($userKey, FILTER_VALIDATE_EMAIL)) {
         $key = 'id';
         $userKey = intval($userKey);
     }
     // ensure that user exists in db
     $dir = new \SilMock\Google\Service\Directory('anything', $this->_dbFile);
     $matchingUsers = $dir->users->get($userKey);
     if ($matchingUsers === null) {
         throw new \Exception("Account doesn't exist: " . $userKey, 201407101645);
     }
     // Get all the aliases for that user
     $sqliteUtils = new SqliteUtils($this->_dbFile);
     $aliases = $sqliteUtils->getAllRecordsByDataKey($this->_dataType, $this->_dataClass, $key, $userKey);
     if (!$aliases) {
         return null;
     }
     // Check the data of each alias and when there is a match,
     // delete that alias and return true
     foreach ($aliases as $nextAlias) {
         $aliasData = json_decode($nextAlias['data'], true);
         if ($aliasData['alias'] === $alias) {
             $sqliteUtils->deleteRecordById(intval($nextAlias['id']));
             return true;
         }
     }
     return null;
 }
 /**
  * Deletes a user (users.delete)
  *
  * @param string $userKey - The Email or immutable Id of the user
  * @return null|true depending on if the user was found.
  */
 public function delete($userKey)
 {
     $userEntry = $this->getDbUser($userKey);
     if ($userEntry === null) {
         return null;
     }
     $sqliteUtils = new SqliteUtils($this->_dbFile);
     $sqliteUtils->deleteRecordById($userEntry['id']);
     return true;
 }