original_string: public function write(&$result)
      {
          $entity = $this->accessor->getPropertyValue($result, $this->definition->container());
          if (empty($entity)) {
              $conditions = [];
              foreach ($this->definition->keys() as $local => $foreign) {
                  $conditions[$foreign][] = $this->accessor->getPropertyValue($result, $local);
              }
  
              $this->cleanup($this->definition->entity(), [], $conditions);
              return $result;
          }
  
          $this->assertInstance($entity);
  
          foreach ($this->definition->keys() as $local => $foreign) {
              $this->accessor->setPropertyValue($entity, $foreign, $this->accessor->getPropertyValue($result, $local));
          }
  
          $this->storage->write($entity, $this->definition->entity())->execute();
          $this->accessor->setPropertyValue($result, $this->definition->container(), $entity);
  
          return $result;
      }
code: public function write(&$result)
      {
          $entity = $this->accessor->getPropertyValue($result, $this->definition->container());
          if (empty($entity)) {
              $conditions = [];
              foreach ($this->definition->keys() as $local => $foreign) {
                  $conditions[$foreign][] = $this->accessor->getPropertyValue($result, $local);
              }
  
              $this->cleanup($this->definition->entity(), [], $conditions);
              return $result;
          }
  
          $this->assertInstance($entity);
  
          foreach ($this->definition->keys() as $local => $foreign) {
              $this->accessor->setPropertyValue($entity, $foreign, $this->accessor->getPropertyValue($result, $local));
          }
  
          $this->storage->write($entity, $this->definition->entity())->execute();
          $this->accessor->setPropertyValue($result, $this->definition->container(), $entity);
  
          return $result;
      }
code_tokens: public function write ( & $ result ) { $ entity = $ this -> accessor -> getPropertyValue ( $ result , $ this -> definition -> container ( ) ) ; if ( empty ( $ entity ) ) { $ conditions = [ ] ; foreach ( $ this -> definition -> keys ( ) as $ local => $ foreign ) { $ conditions [ $ foreign ] [ ] = $ this -> accessor -> getPropertyValue ( $ result , $ local ) ; } $ this -> cleanup ( $ this -> definition -> entity ( ) , [ ] , $ conditions ) ; return $ result ; } $ this -> assertInstance ( $ entity ) ; foreach ( $ this -> definition -> keys ( ) as $ local => $ foreign ) { $ this -> accessor -> setPropertyValue ( $ entity , $ foreign , $ this -> accessor -> getPropertyValue ( $ result , $ local ) ) ; } $ this -> storage -> write ( $ entity , $ this -> definition -> entity ( ) ) -> execute ( ) ; $ this -> accessor -> setPropertyValue ( $ result , $ this -> definition -> container ( ) , $ entity ) ; return $ result ; }
docstring: Executes write fro one-to-one relation
  
  @param array|\ArrayAccess $result
  
  @return array|\ArrayAccess
  @throws RelationException
docstring_tokens: Executes write fro one - to - one relation