From 89cbb3877888805a58316e693607f38f6c8a9de9 Mon Sep 17 00:00:00 2001 From: Neil Kandalgaonkar Date: Sat, 18 Jun 2011 03:36:44 +0000 Subject: [PATCH] fix invocation of static function --- .../includes/api/RandomImageGenerator.php | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/tests/phpunit/includes/api/RandomImageGenerator.php b/tests/phpunit/includes/api/RandomImageGenerator.php index 75b729f8da..121b2d55e7 100644 --- a/tests/phpunit/includes/api/RandomImageGenerator.php +++ b/tests/phpunit/includes/api/RandomImageGenerator.php @@ -161,6 +161,20 @@ class RandomImageGenerator { return $spec; } + /** + * Given array( array('x' => 10, 'y' => 20), array( 'x' => 30, y=> 5 ) ) + * returns "10,20 30,5" + * Useful for SVG and imagemagick command line arguments + * @param $shape: Array of arrays, each array containing x & y keys mapped to numeric values + * @return string + */ + static function shapePointsToString( $shape ) { + $points = array(); + foreach ( $shape as $point ) { + $points[] = $point['x'] . ',' . $point['y']; + } + return join( " ", $points ); + } /** * Based on image specification, write a very simple SVG file to disk. @@ -179,7 +193,7 @@ class RandomImageGenerator { foreach ( $spec['draws'] as $drawSpec ) { $shape = $g->addChild( 'polygon' ); $shape->addAttribute( 'fill', $drawSpec['fill'] ); - $shape->addAttribute( 'points', shapePointsToString( $drawSpec['shape'] ) ); + $shape->addAttribute( 'points', self::shapePointsToString( $drawSpec['shape'] ) ); }; if ( ! $fh = fopen( $filename, 'w' ) ) { throw new Exception( "couldn't open $filename for writing" ); @@ -190,14 +204,6 @@ class RandomImageGenerator { } } - public function shapePointsToString( $shape ) { - $points = array(); - foreach ( $shape as $point ) { - $points[] = $point['x'] . ',' . $point['y']; - } - return join( " ", $points ); - } - /** * Based on an image specification, write such an image to disk, using Imagick PHP extension * @param $spec: spec describing background and circles to draw @@ -240,7 +246,7 @@ class RandomImageGenerator { $args[] = wfEscapeShellArg( "xc:" . $spec['fill'] ); foreach( $spec['draws'] as $draw ) { $fill = $draw['fill']; - $polygon = shapePointsToString( $draw['shape'] ); + $polygon = self::shapePointsToString( $draw['shape'] ); $drawCommand = "fill $fill polygon $polygon"; $args[] = '-draw ' . wfEscapeShellArg( $drawCommand ); } -- 2.20.1