src/PicORM/Model.php
protected static function addRelationOneToOne(
        $sourceField,
        $classRelation,
        $targetField,
        $autoGetFields = array(),
        $aliasRelation = ''
    )
    {
        if (!is_string($sourceField)) {
            throw new Exception('$sourceField have to be a string');
        }
        if (!is_string($classRelation)) {
            throw new Exception('$classRelation have to be a string');
        }
        if (!is_string($targetField)) {
            throw new Exception('$targetField have to be a string');
        }

        // test is related class is a PicORM model
        if (!class_exists($classRelation) || !new $classRelation() instanceof Model) {
            throw new Exception("Class " . $classRelation . " doesn't exists or is not subclass of \PicORM\Model");
        }

        // test if its needed to autoget all fields
        if ($autoGetFields === true) {
            $autoGetFields = $classRelation::getModelFields();
        }

        // store autogetfields as an array
        if (!is_array($autoGetFields)) {
            $autoGetFields = array($autoGetFields);
        }

        // create relation id with normalized classRelation name
        $idRelation = self :: formatClassnameToRelationName($classRelation);

        // override the relation's id if an alias is present
        if (!empty($aliasRelation)) {
            $idRelation = strtolower($aliasRelation);
        }

        // store new relation in model
        static::$_relations[$idRelation] = array(
            'typeRelation'  => self::ONE_TO_ONE,
            'classRelation' => $classRelation,
            'sourceField'   => $sourceField,
            'targetField'   => $targetField,
            'autoGetFields' => $autoGetFields
        );
    }
protected static function addRelationOneToOne(
        $sourceField,
        $classRelation,
        $targetField,
        $autoGetFields = array(),
        $aliasRelation = ''
    )
    {
        if (!is_string($sourceField)) {
            throw new Exception('$sourceField have to be a string');
        }
        if (!is_string($classRelation)) {
            throw new Exception('$classRelation have to be a string');
        }
        if (!is_string($targetField)) {
            throw new Exception('$targetField have to be a string');
        }

        // test is related class is a PicORM model
        if (!class_exists($classRelation) || !new $classRelation() instanceof Model) {
            throw new Exception("Class " . $classRelation . " doesn't exists or is not subclass of \PicORM\Model");
        }

        // test if its needed to autoget all fields
        if ($autoGetFields === true) {
            $autoGetFields = $classRelation::getModelFields();
        }

        // store autogetfields as an array
        if (!is_array($autoGetFields)) {
            $autoGetFields = array($autoGetFields);
        }

        // create relation id with normalized classRelation name
        $idRelation = self :: formatClassnameToRelationName($classRelation);

        // override the relation's id if an alias is present
        if (!empty($aliasRelation)) {
            $idRelation = strtolower($aliasRelation);
        }

        // store new relation in model
        static::$_relations[$idRelation] = array(
            'typeRelation'  => self::ONE_TO_ONE,
            'classRelation' => $classRelation,
            'sourceField'   => $sourceField,
            'targetField'   => $targetField,
            'autoGetFields' => $autoGetFields
        );
    }
Add a OneToOne relation

@param string $sourceField   - model source field
@param string $classRelation - relation model classname
@param string $targetField   - related model target field
@param array  $autoGetFields - field to auto get from relation when loading model
@param string $aliasRelation - override relation auto naming with an alias (ex : for reflexive relation)

@throws Exception

@return void