Overview

Classes

  • xu
  • Xu\Foundation\Foundation
  • Xu\Foundation\Jsonable
  • Xu\Model\Collection
  • Xu\Model\Model

Functions

  • xu
  • xu_add_option
  • xu_attachment_url_to_postid
  • xu_cache_delete
  • xu_cache_delete_group
  • xu_cache_get
  • xu_cache_key
  • xu_camel_case
  • xu_clean_attachment_cache
  • xu_clean_nav_menu_cache
  • xu_clean_post_cache
  • xu_contains
  • xu_convert_to_string
  • xu_current_attachment_url_to_postid
  • xu_current_url
  • xu_current_url_to_postid
  • xu_dashify
  • xu_delete_option
  • xu_delete_site_transient
  • xu_delete_transient
  • xu_doing_ajax
  • xu_ends_with
  • xu_get_class_name
  • xu_get_model
  • xu_get_option
  • xu_get_option_name
  • xu_get_option_post_id
  • xu_get_posts
  • xu_get_site_transient
  • xu_get_top_parent_post
  • xu_get_top_parent_post_type
  • xu_get_top_parent_post_type_object
  • xu_get_transient
  • xu_is_empty
  • xu_is_http_method
  • xu_is_json
  • xu_is_post_type
  • xu_is_wp
  • xu_is_xml
  • xu_post_exists
  • xu_register_large_option_post_type
  • xu_snake_case
  • xu_starts_with
  • xu_strip_spaces
  • xu_studly_case
  • xu_update_option
  • xu_url_to_postid
  • xu_valid_personnummer
  • xu_wp_get_attachment_image
  • xu_wp_get_attachment_image_sizes
  • xu_wp_get_attachment_image_src
  • xu_wp_get_attachment_image_srcset
  • xu_wp_get_attachment_url
  • xu_wp_nav_menu
  • Overview
  • Class

Class Collection

Xu\Foundation\Jsonable
Extended by Xu\Model\Collection implements ArrayAccess
Namespace: Xu\Model
Located at model/class-collection.php
Methods summary
public
# __construct( array $items = [] )

The constructor.

The constructor.

Parameters

$items
public array
# all( )

Get all models in the collection.

Get all models in the collection.

Returns

array
public integer
# count( )

Get number of items that exists in the collection.

Get number of items that exists in the collection.

Returns

integer
public mixed
# eq( string $offset )

Get item in collection.

Get item in collection.

Parameters

$offset

Returns

mixed
public array
# filter( callable|string $callback, mixed $value = null )

Create a collection of all elements that do pass the given truth test.

Create a collection of all elements that do pass the given truth test.

Parameters

$callback
$value

Returns

array
protected mixed
# find_in_item( mixed $attributes, string $key, mxied $default = null )

Find attribute value by key.

Find attribute value by key.

Parameters

$attributes
$key
$default

Returns

mixed
public mixed
# first( callable $callback = null )

Get the first item in the collection.

Get the first item in the collection.

Parameters

$callback

Returns

mixed
public boolean
# is_empty( )

Determine if the collection is empty or not.

Determine if the collection is empty or not.

Returns

boolean
public mixed
# last( callable $callback = null )

Get the last item in the collection.

Get the last item in the collection.

Parameters

$callback

Returns

mixed
public Xu\Model\Collection
# map( callable $callback )

Run map over each of the items.

Run map over each of the items.

Parameters

$callback

Returns

Xu\Model\Collection
public boolean
# offsetExists( mixed $offset )

Determine if the given offset exists.

Determine if the given offset exists.

Parameters

$offset

Returns

boolean

Implementation of

ArrayAccess::offsetExists()
public mixed
# offsetGet( mixed $offset )

Get the value for a given offset.

Get the value for a given offset.

Parameters

$offset

Returns

mixed

Implementation of

ArrayAccess::offsetGet()
public
# offsetSet( mixed $offset, mixed $value )

Set the value for a given offset.

Set the value for a given offset.

Parameters

$offset
$value

Implementation of

ArrayAccess::offsetSet()
public
# offsetUnset( mixed $offset )

Unset the value for a given offset.

Unset the value for a given offset.

Parameters

$offset

Implementation of

ArrayAccess::offsetUnset()
public array
# pluck( string $key )

Pluck a certain field out of each item in a list.

Pluck a certain field out of each item in a list.

Parameters

$key

Returns

array
public mixed
# pop( )

Removes and return the last item from the collection.

Removes and return the last item from the collection.

Returns

mixed
public Xu\Model\Collection
# reject( callable|string $callback, mixed $value = null )

Create a collection of all elements that do not pass the given truth test.

Create a collection of all elements that do not pass the given truth test.

Parameters

$callback
$value

Returns

Xu\Model\Collection
public array
# reverse( )

Reverse the collection items.

Reverse the collection items.

Returns

array
public mixed
# shift( )

Removes and return the first item from the collection.

Removes and return the first item from the collection.

Returns

mixed
public Xu\Model\Collection
# slice( integer $offset, integer $length = null, boolean $preserve_keys = false )

Extract a slice of the collection.

Extract a slice of the collection.

Parameters

$offset
$length
$preserve_keys

Returns

Xu\Model\Collection
public Xu\Model\Collection
# sort( callable $callback )

Sort through each item in the collection.

Sort through each item in the collection.

Parameters

$callback

Returns

Xu\Model\Collection
public Xu\Model\Collection
# where( string $key, mixed $value = null )

Filter models by the given key value pair.

Filter models by the given key value pair.

Parameters

$key
$value

Returns

Xu\Model\Collection
public array
# to_array( )

Convert the collection items to an array.

Convert the collection items to an array.

Returns

array
Methods inherited from Xu\Foundation\Jsonable
json_serialize(), to_json()
Properties summary
protected array $items

Collection items.

Collection items.

# []
API documentation generated by ApiGen