Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Interval {
- protected static $names = [
- 0 => ["Perfect unison", "P1"],
- 1 => ["Minor second", "m2", "S"],
- 2 => ["Major second", "M2", "T"],
- 3 => ["Minor third", "m3"],
- 4 => ["Major third", "M3"],
- 5 => ["Perfect fourth", "P4"],
- 6 => ["Diminished fifth", "Augmented fourth"],
- 7 => ["Perfect fifth", "P5"],
- 8 => ["Minor sixth", "m6"],
- 9 => ["Major sixth", "M6"],
- 10 => ["Minor seventh", "m7"],
- 11 => ["Major seventh", "M7"],
- 12 => ["Perfect octave", "P8"],
- ];
- protected $size;
- public function __get($name) {
- switch ($name) {
- case "Size":
- return $this->size;
- case "Name":
- return self::$names[$this->Size][0] ?: $this->Size.'S';
- }
- }
- public function __toString() {
- return $this->Name;
- }
- public function __construct($size) {
- if(is_string($size)) {
- foreach(self::$names as $k => $v) {
- if(in_array($size, $v)) {
- $size = $k;
- break;
- }
- }
- }
- $this->size = $size;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement