My library for 2 dimensional shapes This is my first OOP PHP library and wanted to get advice on how I can improve what I wrote. This is what I needed to do:

I'm also not sure on what it meant by "proportionally resize the shape up or down, given a floating-point scale factor" I think what I did what it meant but I could be wrong.


  Build a simple PHP library for defining 2-dimensional geometric shapes and making basic calculations with them.
  
  For each shape, the library should be able to do the following:
  
  
  calculate the area
  calculate the perimeter
  proportionally resize the shape up or down, given a floating-point scale factor
  




&lt;?PHP
echo "Circle &lt;br/&gt;";
$circle = new circle(5);
$circle-&gt;getArea();
$circle-&gt;getPerimiter();
$circle-&gt;scale(up, .5);
$circle-&gt;getArea();
$circle-&gt;getPerimiter();

echo "&lt;br/&gt;Right Triangle &lt;br/&gt;";
$rt = new RightTriangle(4, 5);
$rt-&gt;getArea();
$rt-&gt;getPerimiter();
$rt-&gt;scale(up, .5);
$rt-&gt;getArea();
$rt-&gt;getPerimiter();

class Circle {
    public function __construct( $radius )
    {
        $this-&gt;radius = $radius;
    }
    public function getArea()
    {
        echo pow($this-&gt;radius, 2) * M_PI."&lt;br/&gt;";
    }
    public function getPerimiter()
    {
        echo 2 * M_PI * $this-&gt;radius."&lt;br/&gt;";
    }
    public function scale($direction, $scale)
    {
        if($direction == 'up')
        {
            $this-&gt;radius = $this-&gt;radius + ($this-&gt;radius * $scale);
        }
        else
        {
            $this-&gt;radius = $this-&gt;radius - ($this-&gt;radius * $scale);
        }
    }
}

class RightTriangle {
    public function __construct( $a, $b )
    {
        $this-&gt;a = $a;
        $this-&gt;b = $b;
    }
    public function getArea()
    {
        echo ($this-&gt;a*$this-&gt;b/2)."&lt;br/&gt;";
    }
    public function getPerimiter()
    {
        echo $this-&gt;a + $this-&gt;b + sqrt(pow($this-&gt;a, 2) + pow($this-&gt;b, 2))."&lt;br/&gt;";
    }
    public function scale($direction, $scale)
    {
        if($direction == 'up')
        {
            $this-&gt;a = $this-&gt;a + ($this-&gt;a * $scale);
            $this-&gt;b = $this-&gt;b + ($this-&gt;b * $scale);
        }
        else
        {
            $this-&gt;a = $this-&gt;a - ($this-&gt;a * $scale);
            $this-&gt;b = $this-&gt;b + ($this-&gt;b * $scale);
        }
    }
}
?&gt;
The floating point scale factor could control both magnitude and direction without the need for your $direction parameter.  If you want to double the size the $scale = 2.0, if you want to halve it the $scale = 0.5

and this is just personal preference if you were to stick with your $direction parameter in your scaling functions.  Create a static class constant so you don't have to hardcode 'up' and 'down' all over the place.

&lt;?
    $circle = new Circle(5);
    $circle-&gt;scale(Circle::UP, 2);

    Class Cirlce {
        const UP = 'up';
        const DOWN = 'down';
    .
    .
    .
    }