You are here

public static function SassExtentionsCompassFunctionsConstants::opposite_position in Sassy 7

File

phamlp/sass/extensions/compass/functions/constants.php, line 19

Class

SassExtentionsCompassFunctionsConstants
Compass extension SassScript constants functions class. A collection of functions for use in SassSCript. @package PHamlP @subpackage Sass.extensions.compass.functions

Code

public static function opposite_position($pos) {
  $opposites = array();
  foreach (explode(' ', $pos
    ->toString()) as $position) {
    switch (trim($position)) {
      case 'top':
        $opposites[] = 'bottom';
        break;
      case 'right':
        $opposites[] = 'left';
        break;
      case 'bottom':
        $opposites[] = 'top';
        break;
      case 'left':
        $opposites[] = 'right';
        break;
      case 'center':
        $opposites[] = 'center';
        break;
      default:
        throw new Exception('Cannot determine the opposite of ' . trim($position));
    }
  }
  return new SassString(join(' ', $opposites));
}