Example #1
0
 public static function main()
 {
     $cliEndpoint = new self();
     //$cliEndpoint->setDefaults();
     $cliEndpoint->handle();
 }
Example #2
0
 /**
  * Load kernel, handle a request from a webserver and send the response
  *
  * Utility function for the entrypoint of your application, only use when you are in a request context (from a webserver)
  */
 public static function boot(Request $request, RouteCollection $routeCollection, Container $container)
 {
     try {
         $kernel = new self($routeCollection, $container);
         $kernel->configureErrors();
         $response = $kernel->handle($request, HttpKernelInterface::MASTER_REQUEST, true);
         $response->send();
         if ($kernel instanceof TerminableInterface) {
             $kernel->terminate($request, $response);
         }
     } catch (\Exception $exception) {
         $kernel->uncaughtRenderer->render($exception);
     }
 }
Example #3
0
	public static function run() {
		$singleton = new self();
		$singleton->handle();
	}
Example #4
0
 /**
  * Do a pixel by pixel comparation of two images
  * @warning this function can take several minutes on large files
  *
  * @param mixed $image_a Path or handle to the first image
  * @param mixed $image_b Path or handle to the second image
  *
  * @return bool
  */
 public static function equal($image_a, $image_b)
 {
     if (!$image_a instanceof self) {
         $image_a = new self($image_a);
     }
     if (!$image_b instanceof self) {
         $image_b = new self($image_b);
     }
     //Compare size
     if ($image_a->width() != $image_b->width() || $image_a->height() != $image_b->height()) {
         return false;
     }
     //Compare pixel
     $ha = $image_a->handle();
     $hb = $image_b->handle();
     for ($x = 0; $x <= imagesx($ha) - 1; $x++) {
         for ($y = 0; $y <= imagesy($ha) - 1; $y++) {
             $color_a = imagecolorsforindex($ha, imagecolorat($ha, $x, $y));
             $color_b = imagecolorsforindex($hb, imagecolorat($hb, $x, $y));
             if ($color_a != $color_b) {
                 //If alfa value is zero, color doesn't matter
                 if ($color_b['alpha'] != 0 || $color_b['alpha'] != 0) {
                     return false;
                 }
             }
         }
     }
     return true;
 }
Example #5
0
 /** rotate image clockwise and automatically adjust height/width;
  * beware: only 90¡/-90¡/180¡ are supported */
 public function rotate($angle)
 {
     switch ($angle) {
         case 90:
         case -90:
             $height = $this->width;
             $width = $this->height;
             break;
         case 180:
             $width = $this->width;
             $height = $this->height;
             break;
         default:
             throw new ImageException("angle must be 90, -90 or 180.");
     }
     $new = new self();
     $new->createtruecolor($width, $height);
     $new->preparecopy($this);
     for ($y = 0; $y < $this->height(); $y++) {
         for ($x = 0; $x < $this->width(); $x++) {
             $color = $this->colorat($x, $y);
             switch ($angle) {
                 case 90:
                     $new->setpixel($width - $y - 1, $x, $color);
                     break;
                 case -90:
                     $new->setpixel($y, $height - $x - 1, $color);
                     break;
                 case 180:
                     $new->setpixel($width - $x - 1, $height - $y - 1, $color);
                     break;
             }
         }
     }
     $this->sethandle($new->handle());
     return $this;
 }
Example #6
0
 /**
  * create renderer instance and handle requests
  */
 public static function create($pRequest)
 {
     $instance = new self($pRequest);
     $instance->handle();
 }