Advertisement
Guest User

php_style_generating_class

a guest
Sep 1st, 2015
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.94 KB | None | 0 0
  1. <?php
  2.  
  3. class Column {
  4.     function Column($span, $size) {
  5.         // Makes you even lazier by returning Bootstrap column length and size for style attr
  6.         $span_options = array(  1 => "1", 2 => "2", 3 => "3", 4 => "4",
  7.                                 5 => "5", 6 => "6", 7 => "7", 8 => "8",
  8.                                 9 => "9", 10 => "10", 11 => "11", 12 => "12"
  9.                             );
  10.  
  11.         $size_options = array("xs", "sm", "md", "lg");
  12.         $size_options_mapping = array(0,1,2,3);
  13.  
  14.         $a = in_array($span, $span_options);
  15.         $b = in_array($size, $size_options_mapping);
  16.  
  17.         if ( $a and $b ) {
  18.             $this->size = $size_options[$size];
  19.             $this->span = $span_options[$span];
  20.         } else {
  21.             trigger_error(" First parameter is the bootstrap column length (int 0 - 12). \n
  22.                 Second parameter is the bootstrap column size (xs, sm, md, lg). ", E_USER_ERROR);
  23.         }
  24.        
  25.     }
  26.  
  27.     function style() {
  28.         if ( isset($this->span) && isset($this->size) ) {
  29.             echo "col-". $this->size . "-" . $this->span;
  30.         }
  31.     }
  32. }
  33.  
  34. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement