| 1 | <?php |
||
| 10 | abstract class Translator { |
||
| 11 | |||
| 12 | /** |
||
| 13 | * Translate a Fulfillable to foreign data |
||
| 14 | * |
||
| 15 | * @param Fulfillable $fulfillable |
||
| 16 | * @return mixed |
||
| 17 | */ |
||
| 18 | 1 | public function fulfillable_to_foreign( Fulfillable $fulfillable ) { |
|
| 19 | if ( is_a( $fulfillable, 'Carbon_Fields\\Container\\Condition\\Condition' ) ) { |
||
| 20 | return $this->condition_to_foreign( $fulfillable ); |
||
| 21 | } |
||
| 22 | |||
| 23 | if ( is_a( $fulfillable, 'Carbon_Fields\\Container\\Fulfillable\\Fulfillable_Collection' ) ) { |
||
| 24 | return $this->fulfillable_collection_to_foreign( $fulfillable ); |
||
| 25 | } |
||
| 26 | |||
| 27 | Incorrect_Syntax_Exception::raise( 'Attempted to translate an unsupported object: ' . print_r( $fulfillable, true ) ); |
||
| 28 | 1 | } |
|
| 29 | |||
| 30 | /** |
||
| 31 | * Translate a Condition to foreign data |
||
| 32 | * |
||
| 33 | * @param Condition $condition |
||
| 34 | * @return mixed |
||
| 35 | */ |
||
| 36 | abstract protected function condition_to_foreign( Condition $condition ); |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Translate a Fulfillable_Collection to foreign data |
||
| 40 | * |
||
| 41 | * @param Fulfillable_Collection $fulfillable_collection |
||
| 42 | * @return mixed |
||
| 43 | */ |
||
| 44 | abstract protected function fulfillable_collection_to_foreign( Fulfillable_Collection $fulfillable_collection ); |
||
| 45 | |||
| 46 | /** |
||
| 47 | * Translate foreign data to a Fulfillable |
||
| 48 | * |
||
| 49 | * @param mixed $foreign |
||
| 50 | * @return Fulfillable |
||
| 51 | */ |
||
| 52 | abstract public function foreign_to_fulfillable( $foreign ); |
||
| 53 | } |
||
| 54 |