Пример #1
0
 /**
  * Adds a key to the key set.
  *
  * This function checks whether an identical key (whether by key ID or by
  * key contents) already exists in the key set.
  *
  * @param Key $key the key to add
  * @throws KeyException if there is an identical key
  */
 function add($key)
 {
     $signature = $key->getSignature();
     foreach ($this->keys as $existing_key) {
         if ($existing_key->getSignature() == $signature) {
             throw new KeyException('Key already exists');
         }
         if ($existing_key->getKeyID() == $key->getKeyID()) {
             throw new KeyException('Key already exists');
         }
     }
     $this->keys[] = $key;
 }