webkit::toPng()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 1
dl 0
loc 14
rs 9.7998
c 0
b 0
f 0
ccs 0
cts 13
cp 0
crap 12
1
<?php
2
	/*
3
4
	*/
5
6
	class pinp_webkit {
7
8
		function _toPng($url) {
9
			return webkit::toPng($url);
10
		}
11
12
	}
13
14
	class webkit {
15
16
		function toPng( $url ) {
17
			global $AR;
18
			$image = false;
19
			if ( $AR->Webkit2png->path ) {
20
				$url = ar::url($url);
21
				if ( $url->host ) { // only allow remote fetches
0 ignored issues
show
Documentation introduced by
The property host does not exist on object<ar_url>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
22
					$cmd = $AR->Webkit2png->xvfbPath . ' ' . $AR->Webkit2png->xvfbOptions
23
					. ' ' . $AR->Webkit2png->path . ' ' . $AR->Webkit2png->options . ' ' . escapeshellarg( (string) $url );
24
					//echo $cmd;
25
					$image = shell_exec( $cmd );
26
				}
27
			}
28
			return $image;
29
		}
30
31
	}
32