@param Collection $remote
@param SettingInterface $object

@return bool
165128
private function exists(Collection $remote, SettingInterface $object): bool
    {
        return $remote->exists(function (int $key, SettingInterface $setting) use ($object) {
            return $setting->isEqual($object);
        });
    }
806358
private function savePropertiesDirectly(Remote\Model $object)
    {
        foreach ($object::getProperties() as $property_name => $meta) {
            if ($meta[Remote\Model::KEY_SAVE_DIRECTLY] && $object->isDirty($property_name)) {
                //Then actually save
                $property_objects = $object->$property_name;
                /** @var Remote\Model $property_type */
                $property_type = get_class(current($property_objects));

                $url = new URL($this, sprintf('%s/%s/%s', $object::getResourceURI(), $object->getGUID(), $property_type::getResourceURI()));
                $request = new Request($this, $url, Request::METHOD_PUT);

                $property_array = [];
                /** @var Remote\Model[] $property_objects */
                foreach ($property_objects as $property_object) {
                    $property_array[] = $property_object->toStringArray(false);
                }

                $root_node_name = Helpers::pluralize($property_type::getRootNodeName());
                $request->setBody(Helpers::arrayToXML([$root_node_name => $property_array]));

                $request->send();

                $response = $request->getResponse();
                foreach ($response->getElements() as $element_index => $element) {
                    if ($response->getErrorsForElement($element_index) === null) {
                        $property_objects[$element_index]->fromStringArray($element);
                        $property_objects[$element_index]->setClean();
                    }
                }

                //Set it clean so the following save might have nothing to do.
                $object->setClean($property_name);
            }
        }
    }
537213
public function setDocument($url, RemoteDocument $document)
    {
        // Process the context
        if (isset($document->document->{'@context'}) && is_object($document->document->{'@context'})) {
            $this->processContext((array)$document->document->{'@context'});
        }

        // Save the document to the cache
        $docUrlHash     = $this->getCacheHash($url, self::SLOT_DOC);
        $cachedDocument = Cache::getAdapter()->getItem($docUrlHash);
        $cachedDocument->set($document);
        Cache::getAdapter()->save($cachedDocument);

        // Return the document
        return $document;
    }
289028
public function push($remote = null, $branch = null)
    {
        $result = $this->command . ' push ' . $remote . ' ' . $branch;
        return $result;
    }
166702
public function offsetSet($object, $data = null)
       {
            if (! parent::contains($object)) {
                parent::attach($object, $data);
                $this->map[$this->index++] = spl_object_hash($object);
                while(parent::valid()) {
                    parent::next();
                }
            }
       }
1097010
public function set(RelationshipInterface $relationship): RelationshipCollectionInterface
    {
        $this->collection[$relationship->name()] = $relationship;

        return $this;
    }
1318435
public function hasMany($model, $local = null, $remote = null)
     {
         return (new OneToMany())->ini($model, $this, $local, $remote);
     }
261263
public function get($remote, $local)
    {
        foreach ($this->connections as $connection) {
            $connection->get($remote, $local);
        }
    }
877084
public function setPropertyValue( core_kernel_classes_Property $property, $object)
    {
        $returnValue = (bool) false;
        $returnValue = $this->getImplementation()->setPropertyValue($this, $property, $object);
        $this->onUpdate();
        return (bool) $returnValue;
    }
713539
public function offsetSet($offset, $object)
    {
        if (is_int($offset) && $offset >= 0 && $offset < $this->count()) {
            $member = static::checkMember($object);
            # TODO: merge if duplicated
            if (!$this->contains($member)) {
                $this->members[$offset] = $member;
            }
        } elseif (is_null($object)) {
            $this->closed = false;
        } else {
            $this->append($object);
        }
    }
374550
public static function configure(ObjectInterface $object, $properties)
    {
        // Populate model attributes
        if (!empty($properties)) {
            // To array
            if (!is_array($properties)) {
                $properties = ArrayHelper::toArray($properties, [], false);
            }

            foreach ($properties as $name => $value) {
                if ($object->canSetProperty($name)) {
                    $object->$name = $value;
                }
            }
        }
        return $object;
    }
1348885
public static function bind($key, $object = null)
    {
        if(is_array($key))
        {
            foreach($key as $key => $object)
            {
                self::$bindings[$key] = $object;
            }
        }
        else
        {
            self::$bindings[$key] = $object;
        }
    }
780036
public function initBySetting($model, $setting)
    {
        parent::initBySetting($model, $setting);
        if (is_array($setting)) {
            if (isset($setting['remote_class_type'])) {
                $this->remoteModelType = $setting['remote_class_type'];
            }
        }
    }
480904
public function setInstance($object, $abstract = null)
    {
        if (!is_object($object)) {
            throw new \InvalidArgumentException('$object must be an object');
        }
        if ($abstract === null) {
            //If $abstract is not specified, use $objects class
            $abstract = get_class($object);
        } elseif ($abstract[0] === '\\') {
            //Strip all leading backslashes
            $abstract = substr($abstract, 1);
        }
        $concrete = $this->findMostConcreteDefinition($abstract);
        if (isset($this->objects[$concrete])) {
            //If this class already has an instance, we'll return the old object
            $old = $this->objects[$concrete];
        } else {
            $old = false;
        }
        //Store the object
        $this->objects[$concrete] = $object;

        return $old;
    }
734227
public function setObjectState($object, $state)
    {
        if (is_object($object)) {
            $oid = spl_object_hash($object);
            $repository = $this->objectsRepository[$oid];
            $data = $repository->getHydrator()->unhydrate($object);
            $id = isset($data['_id']) ? serialize($data['_id']) . $repository->getCollection() : $oid;
        } else {
            return false;
        }

        if (!isset($this->objectStates[$id]) && !isset($this->objectStates[$oid])) {
            throw new Exception\StateException();
        }

        if (!in_array($state, [self::OBJ_MANAGED, self::OBJ_NEW, self::OBJ_REMOVED])) {
            throw new Exception\StateException("Invalid state '$state'");
        }

        if ($state == self::OBJ_REMOVED && isset($this->objectStates[$oid]) && $this->objectStates[$oid] == self::OBJ_NEW) {
            throw new Exception\StateException("Can't change state to removed because object is not managed. Insert it in database before");
        }

        if (isset($this->objectStates[$oid])) {
            unset($this->objectStates[$oid]);
            unset($this->objects[$oid]);
        }

        $this->objectStates[$id] = $state;
        $this->objects[$id] = $object;

        return true;
    }
1110071
public function fetch($remote = null)
    {
        if ($this->isFetched) {
            return false;
        }

        if (!$this->hasClone) {
            $this->checkout();
        }

        $args = array();
        if (null !== $remote) {
            $args[] = $remote;
        }

        $this->execute('fetch', $args);

        $this->isFetched = true;

        return true;
    }
40870
public function setObject(RenderableInterface $object = null)
    {
        $this->__currentelement = null;
        $this->_object = $object;

        if (is_array($this->__vars) && 0 < count($this->__vars)) {
            foreach ($this->__vars as $key => $var) {
                if ($var === $object) {
                    $this->__currentelement = $key;
                }
            }
        }

        return $this;
    }