Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class PHP2CSS {
- private static $stylesheet = [];
- private static $setContenttype = false;
- public static function contentType($contentType) {
- self::$setContenttype = true;
- }
- public static function addStyle() {
- $args = func_get_args();
- $num = func_num_args();
- for($i = 1; $i <= $num; ++$i) {
- if($i % 2 != 0) {
- self::$stylesheet[] = [
- 'name' => $args[$i-1],
- 'styles' => $args[$i]
- ];
- }
- }
- }
- public static function generateStylesheet() {
- if(self::$setContenttype) {
- header('Content-type: '.self::$setContenttype);
- }
- $nStyle = null;
- foreach(self::$stylesheet as $style) {
- $nStyle .= $style['name'].' {'."\n";
- foreach($style['styles'] as $keyword => $value) {
- $nStyle .= "\t".$keyword.': '.$value.";\n";
- }
- $nStyle .= '}'."\n\n";
- }
- echo $nStyle;
- }
- }
- PHP2CSS::addStyle(
- 'body, html', [
- 'background-color' => 'rgba(0,0,0,0.05)',
- 'font-family' => 'Open Sans'
- ],
- '.class', [
- 'font-size' => '300px'
- ],
- '.class', [
- 'font-size' => '300px'
- ]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement