Smutty

MVC Framework

View Code: Smutty_GPG_PublicKey

Browse: All · Classes · Plugins

1
<?php
2
3
/**
4
* represents a GPG public key
5
*
6
*/
7
9
10
/** the name of the keys owner */
11
private $name;
12
13
/** the keys id */
14
private $keyId;
15
16
/**
17
* constructor. this takes an array of lines that were
18
* output by the gpg program when validating the key.
19
* they are then parsed to find the key info.
20
*
21
* @param array $results array of lines
22
* @return nothing
23
*
24
*/
25
26
public function __construct( $results ) {
27
28
// contains names of properties, and a regexp
29
// which will extract that prop from $results
30
$props = array(
31
'name' => '/: "(.+)" /',
32
'keyId' => '/key ([A-Z0-9]+):/'
33
);
34
35
// extract properties from results
36
foreach ( $props as $key => $regexp )
37
foreach ( $results as $line )
38
if ( preg_match($regexp,$line,$matches) )
39
$this->$key = $matches[1];
40
41
}
42
43
/**
44
* returns the keys id
45
*
46
* @return String key id
47
*
48
*/
49
50
public function getKeyId() {
51
return $this->keyId;
52
}
53
54
/**
55
* returns name associated with key
56
*
57
* @return String user name
58
*
59
*/
60
61
public function getName() {
62
return $this->name;
63
}
64
65
}
66
67
?>

The code shown here is the code that is currently running this site. If you want to view the latest SVN version of the code then go to the Subversion repository.