Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

stub some input stuff

  • Loading branch information...
commit 3cb6d17fbb6a87c9557d52436a069557c06691ac 1 parent f7a2d4b
Brennen Bearnes brennen authored

Showing 2 changed files with 63 additions and 0 deletions. Show diff stats Hide diff stats

  1. +21 0 HTML/Input.php
  2. +42 0 HTML/Input/Select.php
21 HTML/Input.php
... ... @@ -0,0 +1,21 @@
  1 +<?php
  2 +namespace SparkLib\HTML;
  3 +
  4 +abstract class Input {
  5 +
  6 + protected $_html;
  7 +
  8 + public static function make ()
  9 + {
  10 + $class = get_called_class();
  11 + return new $class;
  12 + }
  13 +
  14 + public function __toString ()
  15 + {
  16 + return $this->render();
  17 + }
  18 +
  19 + abstract public function render();
  20 +
  21 +}
42 HTML/Input/Select.php
... ... @@ -0,0 +1,42 @@
  1 +<?php
  2 +namespace SparkLib\HTML\Input;
  3 +use \SparkLib\HTML;
  4 +use \SparkLib\Iterator;
  5 +
  6 +class Select extends \SparkLib\HTML\Input {
  7 +
  8 + protected $_options;
  9 + protected $_output;
  10 + protected $_value;
  11 + protected $_title;
  12 +
  13 + public function __construct ()
  14 + {
  15 + }
  16 +
  17 + public function options ($options)
  18 + {
  19 + $this->_options = $options;
  20 + return $this;
  21 + }
  22 +
  23 + public function value ($value)
  24 + {
  25 + $this->_value = $value;
  26 + return $this;
  27 + }
  28 +
  29 + public function title ($title)
  30 + {
  31 + $this->_title = $title;
  32 + return $this;
  33 + }
  34 +
  35 + public function render ()
  36 + {
  37 + if (! isset($this->_output)) {
  38 + $this->_output = implode('', $this->_options->map(function ($thing) { return $thing->parts_tier_name; }));
  39 + }
  40 + return $this->_output;
  41 + }
  42 +}

0 comments on commit 3cb6d17

Please sign in to comment.
Something went wrong with that request. Please try again.