Пример #1
0
 /**
  * @param array $params
  * @throws InvalidArgumentException
  * @throws TooFewArgumentsException
  */
 private function createCanvas(array $params)
 {
     if (count($params) < 2) {
         throw new TooFewArgumentsException();
     }
     if (!DrawingCommand::positiveNaturalArguments($params, 2)) {
         throw new InvalidArgumentException();
     }
     $this->canvas = new Canvas($params[0], $params[1]);
 }
 public function __construct()
 {
     parent::__construct(3);
     $this->setDescription("draw_horizontal_line y:int x1:int x2:int –-- Draws a straight horizontal line on the canvas");
 }
 public function __construct()
 {
     parent::__construct(4);
     $this->setDescription("draw_rectangle x1:int y1:int x2:int y2:int –-- Draws a rectangle, where (x1,y1) is the top right, and (x2,y2) the bottom right corner of the rectangle");
 }
 public function __construct()
 {
     parent::__construct(3);
     $this->setDescription("draw_vertical_line x:int y1:int y2:int –-- Draws a straight vertical line on the canvas");
 }
 /**
  * @dataProvider argumentDataProvider
  */
 public function test_it_correctly_verifies_whether_arguments_are_positive_natural_numbers($args, $count, $expected)
 {
     $result = DrawingCommand::positiveNaturalArguments($args, $count);
     $this->assertEquals($expected, $result);
 }