| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | namespace keeko\tools\model; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | use Propel\Generator\Model\ForeignKey; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Propel\Generator\Model\Table; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use keeko\framework\utils\NameUtils; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | abstract class Relationship { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | 	const ONE_TO_ONE = 'one-to-one'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | 	const ONE_TO_MANY = 'one-to-many'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | 	const MANY_TO_MANY = 'many-to-many'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | 	/** @var Table */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | 	protected $model; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | 	/** @var Table */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | 	protected $foreign; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | 	/** @var ForeignKey */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | 	protected $fk; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | 	 * Returns the type of this relationship | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | 	 *  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | 	 * @return string | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 27 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  | 	abstract public function getType(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | 	 * Returns the model | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | 	 *  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | 	 * @return Table | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | 	public function getModel() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | 		return $this->model; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | 	 * Returns the foreign model | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | 	 *  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | 	 * @return Table | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  | 	public function getForeign() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | 		return $this->foreign; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | 	 * Returns the foreign key | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | 	 *  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  | 	 * @return ForeignKey | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | 	public function getForeignKey() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | 		return $this->fk; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  | 	 * Returns the related name in studly case | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  | 	 * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  | 	abstract public function getRelatedName(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  | 	 * Returns the pluralized related name in studly case | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  | 	 * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  | 	public function getRelatedPluralName() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  | 		return NameUtils::pluralize($this->getRelatedName()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  | 	 * Returns the related type name for usage in api environment (slug, type-name, etc) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  | 	 * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  | 	public function getRelatedTypeName() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  | 		return NameUtils::dasherize($this->getRelatedName()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  | 	 * Returns the pluralized related type name for usage in api environment (slug, type-name, etc) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  | 	 *  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  | 	 * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  | 	public function getRelatedPluralTypeName() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  | 		return NameUtils::pluralize($this->getRelatedTypeName()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  | 	 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  | 	 * Returns the reverse related name in studly case | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  | 	 */ | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 94 |  |  | 	abstract public function getReverseRelatedName(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                        
            
                                    
            
            
                | 95 |  |  | } | 
            
                        
For interface and abstract methods, it is impossible to infer the return type from the immediate code. In these cases, it is generally advisible to explicitly annotate these methods with a
@returndoc comment to communicate to implementors of these methods what they are expected to return.