GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — develop (#1930)
by
unknown
12:28
created

HTTP_Request2_Observer_Download::update()   B

Complexity

Conditions 6
Paths 6

Size

Total Lines 23
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 6
eloc 14
c 1
b 0
f 0
nc 6
nop 1
dl 0
loc 23
rs 8.5906
1
<?php
2
3
/**
4
 * Download a file to disk instead of buffering it in memory.
5
 * 
6
 * Source: https://pear.php.net/manual/en/package.http.http-request2.observers.php
7
 */
8
class HTTP_Request2_Observer_Download implements SplObserver
9
{
10
	protected $filename;
11
	protected $fp;
12
13
	public function __construct($filename)
14
	{
15
		$this->filename = $filename;
16
	}
17
18
	public function update(SplSubject $subject)
19
	{
20
		$event = $subject->getLastEvent();
21
22
		switch($event['name'])
23
		{
24
			case 'receivedHeaders':
25
				$this->fp = @fopen($this->filename, 'wb');
26
				if(!$this->fp)
27
				{
28
					throw new Exception("Cannot open target file '{$filename}'");
29
				}
30
				break;
31
32
			case 'receivedBodyPart':
33
			case 'receivedEncodedBodyPart':
34
				fwrite($this->fp, $event['data']);
35
				break;
36
37
			case 'receivedBody':
38
				fclose($this->fp);
39
		}
40
	}
41
}
42