Baleen\Migrations\Delta\Delta\Delta\Collection\Sortable

class Sortable

A collection of Versions.

property resolver

protected ResolverInterface

__construct($versions =, []ResolverInterface $resolver = null, ComparatorInterface $comparator = null)
Parameters:
sort(ComparatorInterface $comparator = null)

Sort the collection

Parameters:
Returns:

static

getReverse()

Returns a collection with elements sorted in reverse order.

Returns:static
merge(CollectionInterface $collection)

Merges another set into this one, replacing versions that exist and adding those that don’t.

Parameters:
  • $collection (CollectionInterface) –
Returns:

$this

getByPosition($position)

Returns the element at the given position.

Parameters:
  • $position
Returns:

null|DeltaInterface

add($element)
Parameters:
  • $element
isSorted()

Returns whether the collection is sorted or not

Returns:bool
setResolver(ResolverInterface $resolver)
Parameters:
getResolver()
Returns:ResolverInterface
get($key, $resolve = true)

Gets an element.

Parameters:
  • $key (mixed) – If an alias is given then it will be resolved to an element. Otherwise the $key will be used to fetch the element by index.
  • $resolve (bool) – Whether to use the resolver or not.
Returns:

DeltaInterface|null Null if not present

getById($id)

Gets a version by id

Parameters:
  • $id
Returns:

DeltaInterface

indexOfId($id)

Returns the index of the version that has the given id. Returns null if not found.

Parameters:
  • $id (string) –
Returns:

int|null

resolve($alias)

Resolves an alias in to a version

Parameters:
  • $alias (string) –
Returns:

DeltaInterface|null

has($index, $resolve = true)

Returns whether the key exists in the collection.

Parameters:
  • $index
  • $resolve (bool) –
Returns:

bool

validate(DeltaInterface $element)

Returns true if the specified version is valid (can be added) to the collection. Otherwise, it MUST throw an exception.

Parameters:
Returns:

bool

invalidateResolverCache()

invalidateResolverCache

remove($version)
Parameters:
  • $version
Returns:

DeltaInterface|null

addOrReplace(DeltaInterface $version)

Adds a new version to the collection if it doesn’t exist or replaces it if it does.

Parameters: