title: How to use Polymorphism in php for design oriented apps?
body: <p>I'm trying to use <code>OOP</code> in my plugins. The plugin functionality is mostly design oriented, let say if user choose a triangle shape in back end then i should output a div with triangle shape, there are many predefined shapes like this. I have to write different <code>width,height,border-radius</code> etc.  The plugin also has animation feature so i need to check whether animation is checked on,if so then i should check for which kind of animation and then from where to where(left to right or right to left) etc. </p>
  
  <p>The thing is this involves more conditions. Many People, Blog and Author say we need Polymorphism when there is <strong>more conditional statements</strong>. </p>
  
  <p>Here is the sample of my problem. Options used in here are just for sample, I take options from DB. There are javascript functions too. Based on the user options i output different javascript code.</p>
  
  <pre><code>&lt;?php
  
  class test {
  
      function __construct($color, $place, $border, $bordercolor) {
          $this-&gt;color = $color;
          $this-&gt;place = $place;
          $this-&gt;enable_border = $border;
          $this-&gt;border_color = $bordercolor;
      }
  
      function output() {
          ?&gt;
          &lt;style type="text/css"&gt;
              #test{
                  width:150px;
                  height:150px;
                  position:absolute;
                  background-color: &lt;?php echo $this-&gt;color; ?&gt;;
                  &lt;?php
                  if ($this-&gt;place == "TopLeft") {
                      echo "left:0px;";
                      echo "top:0px;";
                  } elseif ($this-&gt;place == "BottomLeft") {
                      echo "left:0px;";
                      echo "Bottom:0px;";
                  } elseif ($this-&gt;place == "TopRight") {
                      echo "right:0px;";
                      echo "top:0px;";
                  } elseif ($this-&gt;place == "BottomRight") {
                      echo "right:0px;";
                      echo "Bottom:0px;";
                  }
                  //for border
                  if ($this-&gt;enable_border == "Yes") {
                      echo "border:2px solid $this-&gt;border_color;";
                  }
                  ?&gt;
              }
          &lt;/style&gt;
          &lt;div id="test"&gt;
              Sample Content
          &lt;/div&gt;
          &lt;?php
      }
  
  }
  
  $obj = new test("red", "BottomRight", "Yes", "black");
  $obj-&gt;output();
  ?&gt;
  </code></pre>
  
  <p>What should i do now. Should i use polymorphism? If so then i have to create so many implementing class this is same as conditional code. What is the difference?</p>
  
  <p>Can anybody give a sample solution to this problem using polymorphism. Am i heading in a right direction? Any help would be appreiciated</p>