blob: 8fe7a4f150b104ba28b5de0665598bb44251aeae (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
<?php
namespace Studip\OAuth2;
class KeyInformation
{
/** @var string */
private $filename;
public function __construct(string $filename)
{
$this->filename = $filename;
}
public function filename(): string
{
return $this->filename;
}
public function exists(): bool
{
return file_exists($this->filename);
}
public function isReadable(): bool
{
return is_readable($this->filename);
}
public function hasProperMode(): bool
{
return $this->mode() === '600' || $this->mode() === '660';
}
public function mode(): string
{
$result = '';
if ($this->isReadable()) {
$stat = stat($this->filename);
if ($stat !== false) {
$result = substr(sprintf('%o', $stat['mode']), -3);
}
}
return $result;
}
}
|