Canvas   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 0
loc 36
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A clear() 0 7 2
A setPixel() 0 3 1
A width() 0 3 1
A height() 0 3 1
A __toString() 0 3 1
1
<?php
2
3
/**
4
 * Pixeler
5
 *
6
 * UTF-8 Dot matrix renderer.
7
 *
8
 * @package pixeler
9
 * @author [email protected]
10
 * @version 1.0
11
 * @copyright Stefano Azzolini - 2014 - http://dreamnoctis.com
12
 */
13
14
namespace Pixeler;
15
16
class Canvas {
17
  protected $screen;
18
  protected $width;
19
  protected $height;
20
  protected $charHeight;
21
  
22
  public function __construct($w,$h){
23
    $this->screen = new Matrix($this->width=$w,$this->height=$h);
24
    $this->charHeight = ceil($h/4);
25
  }
26
27
  public function clear($clear=true){
0 ignored issues
show
Unused Code introduced by
The parameter $clear is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
28
    static $ESC;
29
    $ESC or $ESC = chr(27);
30
    $this->screen->clear();
31
    $h = $this->charHeight +1;
32
    echo $ESC,'[',$h,'A';
33
  }
34
  
35
  public function setPixel($x,$y,$c=1){
36
    $this->screen->setPixel($x,$y,$c);
0 ignored issues
show
Documentation introduced by
$c is of type integer, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
37
  }
38
39
  public function width(){
40
    return $this->width;
41
  }  
42
43
  public function height(){
44
    return $this->height;
45
  }  
46
  
47
  public function __toString(){
48
    return $this->screen->render();
49
  }  
50
     
51
}