code
stringlengths
31
1.39M
docstring
stringlengths
23
16.8k
func_name
stringlengths
1
126
language
stringclasses
1 value
repo
stringlengths
7
63
path
stringlengths
7
166
url
stringlengths
50
220
license
stringclasses
7 values
public function indexAction( \Illuminate\Http\Request $request ) { if( ( $path = $request->route( 'path', $request->input( 'path' ) ) ) === null ) { abort( 404 ); } $context = app( 'aimeos.context' )->get( true ); foreach( array_reverse( self::$fcn ) as $name => $fcn ) { try { return call_user_func_array( $fcn->bindTo( $this, static::class ), [$context, $path] ); } catch( \Exception $e ) { if( $e->getCode() !== 404 ) throw $e; } } abort( 404 ); }
Returns the html of the resolved URLs. @param \Illuminate\Http\Request $request Laravel request object @return \Illuminate\Http\Response Laravel response object containing the generated output
indexAction
php
aimeos/aimeos-laravel
src/Controller/ResolveController.php
https://github.com/aimeos/aimeos-laravel/blob/master/src/Controller/ResolveController.php
MIT
protected function catalog( \Aimeos\MShop\ContextIface $context, string $path ) : ?\Illuminate\Http\Response { $item = \Aimeos\Controller\Frontend::create( $context, 'catalog' )->resolve( $path ); $view = Shop::view(); $params = ( Route::current() ? Route::current()->parameters() : [] ) + Request::all(); $params += ['path' => $path, 'f_name' => $path, 'f_catid' => $item->getId(), 'page' => 'page-catalog-tree']; $helper = new \Aimeos\Base\View\Helper\Param\Standard( $view, $params ); $view->addHelper( 'param', $helper ); foreach( app( 'config' )->get( 'shop.page.catalog-tree' ) as $name ) { $client = Shop::get( $name ); $params['aiheader'][$name] = $client->header(); $params['aibody'][$name] = $client->body(); } return Response::view( Shop::template( 'catalog.tree' ), $params ) ->header( 'Cache-Control', 'private, max-age=' . config( 'shop.cache_maxage', 30 ) ); }
Returns the category page if the give path can be resolved to a category. @param \Aimeos\MShop\ContextIface $context Context object @param string $path URL path to resolve @return Response Response object
catalog
php
aimeos/aimeos-laravel
src/Controller/ResolveController.php
https://github.com/aimeos/aimeos-laravel/blob/master/src/Controller/ResolveController.php
MIT
protected function cms( \Aimeos\MShop\ContextIface $context, string $path ) : ?\Illuminate\Http\Response { \Aimeos\Controller\Frontend::create( $context, 'cms' )->resolve( $path ); $view = Shop::view(); $params = ( Route::current() ? Route::current()->parameters() : [] ) + Request::all(); $params += ['path' => $path, 'page' => 'page-index']; $helper = new \Aimeos\Base\View\Helper\Param\Standard( $view, $params ); $view->addHelper( 'param', $helper ); foreach( app( 'config' )->get( 'shop.page.cms' ) as $name ) { $client = Shop::get( $name ); $params['aiheader'][$name] = $client->header(); $params['aibody'][$name] = $client->body(); } return Response::view( Shop::template( 'page.index' ), $params ) ->header( 'Cache-Control', 'private, max-age=' . config( 'shop.cache_maxage', 30 ) ); }
Returns the CMS page if the give path can be resolved to a CMS page. @param \Aimeos\MShop\ContextIface $context Context object @param string $path URL path to resolve @return Response Response object
cms
php
aimeos/aimeos-laravel
src/Controller/ResolveController.php
https://github.com/aimeos/aimeos-laravel/blob/master/src/Controller/ResolveController.php
MIT
protected function product( \Aimeos\MShop\ContextIface $context, string $path ) : ?\Illuminate\Http\Response { $item = \Aimeos\Controller\Frontend::create( $context, 'product' )->resolve( $path ); $view = Shop::view(); $params = ( Route::current() ? Route::current()->parameters() : [] ) + Request::all(); $params += ['path' => $path, 'd_name' => $path, 'd_prodid' => $item->getId(), 'page' => 'page-catalog-detail']; $helper = new \Aimeos\Base\View\Helper\Param\Standard( $view, $params ); $view->addHelper( 'param', $helper ); foreach( app( 'config' )->get( 'shop.page.catalog-detail' ) as $name ) { $client = Shop::get( $name ); $params['aiheader'][$name] = $client->header(); $params['aibody'][$name] = $client->body(); } return Response::view( Shop::template( 'catalog.detail' ), $params ) ->header( 'Cache-Control', 'private, max-age=' . config( 'shop.cache_maxage', 30 ) ); }
Returns the product page if the give path can be resolved to a product. @param \Aimeos\MShop\ContextIface $context Context object @param string $path URL path to resolve @return Response Response object
product
php
aimeos/aimeos-laravel
src/Controller/ResolveController.php
https://github.com/aimeos/aimeos-laravel/blob/master/src/Controller/ResolveController.php
MIT
public function detailAction() { try { $params = ['page' => 'page-supplier-detail']; foreach( app( 'config' )->get( 'shop.page.supplier-detail' ) as $name ) { $params['aiheader'][$name] = Shop::get( $name )->header(); $params['aibody'][$name] = Shop::get( $name )->body(); } return Response::view( Shop::template( 'supplier.detail' ), $params ) ->header( 'Cache-Control', 'private, max-age=10' ); } catch( \Exception $e ) { if( $e->getCode() >= 400 && $e->getCode() < 600 ) { abort( $e->getCode() ); } throw $e; } }
Returns the html for the supplier detail page. @return \Illuminate\Http\Response Response object with output and headers
detailAction
php
aimeos/aimeos-laravel
src/Controller/SupplierController.php
https://github.com/aimeos/aimeos-laravel/blob/master/src/Controller/SupplierController.php
MIT
protected static function getFacadeAccessor() { return 'aimeos.frontend.attribute'; }
Returns a new attribute frontend controller object @return \Aimeos\Controller\Frontend\Attribute\Iface
getFacadeAccessor
php
aimeos/aimeos-laravel
src/Facades/Attribute.php
https://github.com/aimeos/aimeos-laravel/blob/master/src/Facades/Attribute.php
MIT
protected static function getFacadeAccessor() { return 'aimeos.frontend.basket'; }
Returns a new basket frontend controller object @return \Aimeos\Controller\Frontend\Basket\Iface
getFacadeAccessor
php
aimeos/aimeos-laravel
src/Facades/Basket.php
https://github.com/aimeos/aimeos-laravel/blob/master/src/Facades/Basket.php
MIT
protected static function getFacadeAccessor() { return 'aimeos.frontend.catalog'; }
Returns a new catalog frontend controller object @return \Aimeos\Controller\Frontend\Catalog\Iface
getFacadeAccessor
php
aimeos/aimeos-laravel
src/Facades/Catalog.php
https://github.com/aimeos/aimeos-laravel/blob/master/src/Facades/Catalog.php
MIT
protected static function getFacadeAccessor() { return 'aimeos.frontend.cms'; }
Returns a new CMS frontend controller object @return \Aimeos\Controller\Frontend\Product\Iface
getFacadeAccessor
php
aimeos/aimeos-laravel
src/Facades/Cms.php
https://github.com/aimeos/aimeos-laravel/blob/master/src/Facades/Cms.php
MIT
protected static function getFacadeAccessor() { return 'aimeos.frontend.customer'; }
Returns a new customer frontend controller object @return \Aimeos\Controller\Frontend\Customer\Iface
getFacadeAccessor
php
aimeos/aimeos-laravel
src/Facades/Customer.php
https://github.com/aimeos/aimeos-laravel/blob/master/src/Facades/Customer.php
MIT
protected static function getFacadeAccessor() { return 'aimeos.frontend.locale'; }
Returns a new locale frontend controller object @return \Aimeos\Controller\Frontend\Locale\Iface
getFacadeAccessor
php
aimeos/aimeos-laravel
src/Facades/Locale.php
https://github.com/aimeos/aimeos-laravel/blob/master/src/Facades/Locale.php
MIT
protected static function getFacadeAccessor() { return 'aimeos.frontend.order'; }
Returns a new order frontend controller object @return \Aimeos\Controller\Frontend\Order\Iface
getFacadeAccessor
php
aimeos/aimeos-laravel
src/Facades/Order.php
https://github.com/aimeos/aimeos-laravel/blob/master/src/Facades/Order.php
MIT
protected static function getFacadeAccessor() { return 'aimeos.frontend.product'; }
Returns a new product frontend controller object @return \Aimeos\Controller\Frontend\Product\Iface
getFacadeAccessor
php
aimeos/aimeos-laravel
src/Facades/Product.php
https://github.com/aimeos/aimeos-laravel/blob/master/src/Facades/Product.php
MIT
protected static function getFacadeAccessor() { return 'aimeos.frontend.service'; }
Returns a new service frontend controller object @return \Aimeos\Controller\Frontend\Service\Iface
getFacadeAccessor
php
aimeos/aimeos-laravel
src/Facades/Service.php
https://github.com/aimeos/aimeos-laravel/blob/master/src/Facades/Service.php
MIT
protected static function getFacadeAccessor() { return 'aimeos.shop'; }
Get the registered name of the component. @return string
getFacadeAccessor
php
aimeos/aimeos-laravel
src/Facades/Shop.php
https://github.com/aimeos/aimeos-laravel/blob/master/src/Facades/Shop.php
MIT
protected static function getFacadeAccessor() { return 'aimeos.frontend.stock'; }
Returns a new stock frontend controller object @return \Aimeos\Controller\Frontend\Stock\Iface
getFacadeAccessor
php
aimeos/aimeos-laravel
src/Facades/Stock.php
https://github.com/aimeos/aimeos-laravel/blob/master/src/Facades/Stock.php
MIT
protected static function getFacadeAccessor() { return 'aimeos.frontend.subscription'; }
Returns a new subscription frontend controller object @return \Aimeos\Controller\Frontend\Subscription\Iface
getFacadeAccessor
php
aimeos/aimeos-laravel
src/Facades/Subscription.php
https://github.com/aimeos/aimeos-laravel/blob/master/src/Facades/Subscription.php
MIT
protected static function getFacadeAccessor() { return 'aimeos.frontend.supplier'; }
Returns a new supplier frontend controller object @return \Aimeos\Controller\Frontend\Supplier\Iface
getFacadeAccessor
php
aimeos/aimeos-laravel
src/Facades/Supplier.php
https://github.com/aimeos/aimeos-laravel/blob/master/src/Facades/Supplier.php
MIT
public function __construct(array $data = []) { // Invoke offsetSet() for each value added; in this way, subclasses // may provide additional logic about values added to the array object. foreach ($data as $key => $value) { $this[$key] = $value; } }
Constructs a new array object. @param array<array-key, T> $data The initial items to add to this array.
__construct
php
ramsey/collection
src/AbstractArray.php
https://github.com/ramsey/collection/blob/master/src/AbstractArray.php
MIT
public function getIterator(): Traversable { return new ArrayIterator($this->data); }
Returns an iterator for this array. @link http://php.net/manual/en/iteratoraggregate.getiterator.php IteratorAggregate::getIterator() @return Traversable<array-key, T>
getIterator
php
ramsey/collection
src/AbstractArray.php
https://github.com/ramsey/collection/blob/master/src/AbstractArray.php
MIT
public function offsetExists(mixed $offset): bool { return isset($this->data[$offset]); }
Returns `true` if the given offset exists in this array. @link http://php.net/manual/en/arrayaccess.offsetexists.php ArrayAccess::offsetExists() @param array-key $offset The offset to check.
offsetExists
php
ramsey/collection
src/AbstractArray.php
https://github.com/ramsey/collection/blob/master/src/AbstractArray.php
MIT
public function offsetGet(mixed $offset): mixed { return $this->data[$offset]; }
Returns the value at the specified offset. @link http://php.net/manual/en/arrayaccess.offsetget.php ArrayAccess::offsetGet() @param array-key $offset The offset for which a value should be returned. @return T the value stored at the offset, or null if the offset does not exist.
offsetGet
php
ramsey/collection
src/AbstractArray.php
https://github.com/ramsey/collection/blob/master/src/AbstractArray.php
MIT
public function offsetSet(mixed $offset, mixed $value): void { if ($offset === null) { $this->data[] = $value; } else { $this->data[$offset] = $value; } }
Sets the given value to the given offset in the array. @link http://php.net/manual/en/arrayaccess.offsetset.php ArrayAccess::offsetSet() @param array-key | null $offset The offset to set. If `null`, the value may be set at a numerically-indexed offset. @param T $value The value to set at the given offset.
offsetSet
php
ramsey/collection
src/AbstractArray.php
https://github.com/ramsey/collection/blob/master/src/AbstractArray.php
MIT
public function offsetUnset(mixed $offset): void { unset($this->data[$offset]); }
Removes the given offset and its value from the array. @link http://php.net/manual/en/arrayaccess.offsetunset.php ArrayAccess::offsetUnset() @param array-key $offset The offset to remove from the array.
offsetUnset
php
ramsey/collection
src/AbstractArray.php
https://github.com/ramsey/collection/blob/master/src/AbstractArray.php
MIT
public function __serialize(): array { return $this->data; }
Returns data suitable for PHP serialization. @link https://www.php.net/manual/en/language.oop5.magic.php#language.oop5.magic.serialize @link https://www.php.net/serialize @return array<array-key, T>
__serialize
php
ramsey/collection
src/AbstractArray.php
https://github.com/ramsey/collection/blob/master/src/AbstractArray.php
MIT
public function __unserialize(array $data): void { $this->data = $data; }
Adds unserialized data to the object. @param array<array-key, T> $data
__unserialize
php
ramsey/collection
src/AbstractArray.php
https://github.com/ramsey/collection/blob/master/src/AbstractArray.php
MIT
public function count(): int { return count($this->data); }
Returns the number of items in this array. @link http://php.net/manual/en/countable.count.php Countable::count()
count
php
ramsey/collection
src/AbstractArray.php
https://github.com/ramsey/collection/blob/master/src/AbstractArray.php
MIT
public function add(mixed $element): bool { $this[] = $element; return true; }
@throws InvalidArgumentException if $element is of the wrong type.
add
php
ramsey/collection
src/AbstractCollection.php
https://github.com/ramsey/collection/blob/master/src/AbstractCollection.php
MIT
public function offsetSet(mixed $offset, mixed $value): void { if ($this->checkType($this->getType(), $value) === false) { throw new InvalidArgumentException( 'Value must be of type ' . $this->getType() . '; value is ' . $this->toolValueToString($value), ); } if ($offset === null) { $this->data[] = $value; } else { $this->data[$offset] = $value; } }
@throws InvalidArgumentException if $element is of the wrong type.
offsetSet
php
ramsey/collection
src/AbstractCollection.php
https://github.com/ramsey/collection/blob/master/src/AbstractCollection.php
MIT
public function column(string $propertyOrMethod): array { $temp = []; foreach ($this->data as $item) { $temp[] = $this->extractValue($item, $propertyOrMethod); } return $temp; }
@throws InvalidPropertyOrMethod if the $propertyOrMethod does not exist on the elements in this collection. @throws UnsupportedOperationException if unable to call column() on this collection. @inheritDoc
column
php
ramsey/collection
src/AbstractCollection.php
https://github.com/ramsey/collection/blob/master/src/AbstractCollection.php
MIT
public function first(): mixed { $firstIndex = array_key_first($this->data); if ($firstIndex === null) { throw new NoSuchElementException('Can\'t determine first item. Collection is empty'); } return $this->data[$firstIndex]; }
@return T @throws NoSuchElementException if this collection is empty.
first
php
ramsey/collection
src/AbstractCollection.php
https://github.com/ramsey/collection/blob/master/src/AbstractCollection.php
MIT
public function last(): mixed { $lastIndex = array_key_last($this->data); if ($lastIndex === null) { throw new NoSuchElementException('Can\'t determine last item. Collection is empty'); } return $this->data[$lastIndex]; }
@return T @throws NoSuchElementException if this collection is empty.
last
php
ramsey/collection
src/AbstractCollection.php
https://github.com/ramsey/collection/blob/master/src/AbstractCollection.php
MIT
public function sort(?string $propertyOrMethod = null, Sort $order = Sort::Ascending): CollectionInterface { $collection = clone $this; usort( $collection->data, function (mixed $a, mixed $b) use ($propertyOrMethod, $order): int { $aValue = $this->extractValue($a, $propertyOrMethod); $bValue = $this->extractValue($b, $propertyOrMethod); return ($aValue <=> $bValue) * ($order === Sort::Descending ? -1 : 1); }, ); return $collection; }
@return CollectionInterface<T> @throws InvalidPropertyOrMethod if the $propertyOrMethod does not exist on the elements in this collection. @throws UnsupportedOperationException if unable to call sort() on this collection.
sort
php
ramsey/collection
src/AbstractCollection.php
https://github.com/ramsey/collection/blob/master/src/AbstractCollection.php
MIT
public function filter(callable $callback): CollectionInterface { $collection = clone $this; $collection->data = array_merge([], array_filter($collection->data, $callback)); return $collection; }
@param callable(T): bool $callback A callable to use for filtering elements. @return CollectionInterface<T>
filter
php
ramsey/collection
src/AbstractCollection.php
https://github.com/ramsey/collection/blob/master/src/AbstractCollection.php
MIT
public function where(?string $propertyOrMethod, mixed $value): CollectionInterface { return $this->filter( fn (mixed $item): bool => $this->extractValue($item, $propertyOrMethod) === $value, ); }
@return CollectionInterface<T> @throws InvalidPropertyOrMethod if the $propertyOrMethod does not exist on the elements in this collection. @throws UnsupportedOperationException if unable to call where() on this collection.
where
php
ramsey/collection
src/AbstractCollection.php
https://github.com/ramsey/collection/blob/master/src/AbstractCollection.php
MIT
public function map(callable $callback): CollectionInterface { return new Collection('mixed', array_map($callback, $this->data)); }
@param callable(T): TCallbackReturn $callback A callable to apply to each item of the collection. @return CollectionInterface<TCallbackReturn> @template TCallbackReturn
map
php
ramsey/collection
src/AbstractCollection.php
https://github.com/ramsey/collection/blob/master/src/AbstractCollection.php
MIT
public function reduce(callable $callback, mixed $initial): mixed { return array_reduce($this->data, $callback, $initial); }
@param callable(TCarry, T): TCarry $callback A callable to apply to each item of the collection to reduce it to a single value. @param TCarry $initial This is the initial value provided to the callback. @return TCarry @template TCarry
reduce
php
ramsey/collection
src/AbstractCollection.php
https://github.com/ramsey/collection/blob/master/src/AbstractCollection.php
MIT
public function diff(CollectionInterface $other): CollectionInterface { $this->compareCollectionTypes($other); $diffAtoB = array_udiff($this->data, $other->toArray(), $this->getComparator()); $diffBtoA = array_udiff($other->toArray(), $this->data, $this->getComparator()); $collection = clone $this; $collection->data = array_merge($diffAtoB, $diffBtoA); return $collection; }
@param CollectionInterface<T> $other The collection to check for divergent items. @return CollectionInterface<T> @throws CollectionMismatchException if the compared collections are of differing types.
diff
php
ramsey/collection
src/AbstractCollection.php
https://github.com/ramsey/collection/blob/master/src/AbstractCollection.php
MIT
public function intersect(CollectionInterface $other): CollectionInterface { $this->compareCollectionTypes($other); $collection = clone $this; $collection->data = array_uintersect($this->data, $other->toArray(), $this->getComparator()); return $collection; }
@param CollectionInterface<T> $other The collection to check for intersecting items. @return CollectionInterface<T> @throws CollectionMismatchException if the compared collections are of differing types.
intersect
php
ramsey/collection
src/AbstractCollection.php
https://github.com/ramsey/collection/blob/master/src/AbstractCollection.php
MIT
public function merge(CollectionInterface ...$collections): CollectionInterface { $mergedCollection = clone $this; foreach ($collections as $index => $collection) { if (!$collection instanceof static) { throw new CollectionMismatchException( sprintf('Collection with index %d must be of type %s', $index, static::class), ); } // When using generics (Collection.php, Set.php, etc), // we also need to make sure that the internal types match each other if ($this->getUniformType($collection) !== $this->getUniformType($this)) { throw new CollectionMismatchException( sprintf( 'Collection items in collection with index %d must be of type %s', $index, $this->getType(), ), ); } foreach ($collection as $key => $value) { if (is_int($key)) { $mergedCollection[] = $value; } else { $mergedCollection[$key] = $value; } } } return $mergedCollection; }
@param CollectionInterface<T> ...$collections The collections to merge. @return CollectionInterface<T> @throws CollectionMismatchException if unable to merge any of the given collections or items within the given collections due to type mismatch errors.
merge
php
ramsey/collection
src/AbstractCollection.php
https://github.com/ramsey/collection/blob/master/src/AbstractCollection.php
MIT
public function __construct(private readonly string $collectionType, array $data = []) { parent::__construct($data); }
Constructs a collection object of the specified type, optionally with the specified data. @param string $collectionType The type or class name associated with this collection. @param array<array-key, T> $data The initial items to store in the collection.
__construct
php
ramsey/collection
src/Collection.php
https://github.com/ramsey/collection/blob/master/src/Collection.php
MIT
public function __construct(private readonly string $queueType, array $data = []) { parent::__construct($this->queueType, $data); }
Constructs a double-ended queue (dequeue) object of the specified type, optionally with the specified data. @param string $queueType The type or class name associated with this dequeue. @param array<array-key, T> $data The initial items to store in the dequeue.
__construct
php
ramsey/collection
src/DoubleEndedQueue.php
https://github.com/ramsey/collection/blob/master/src/DoubleEndedQueue.php
MIT
public function addFirst(mixed $element): bool { if ($this->checkType($this->getType(), $element) === false) { throw new InvalidArgumentException( 'Value must be of type ' . $this->getType() . '; value is ' . $this->toolValueToString($element), ); } array_unshift($this->data, $element); return true; }
@throws InvalidArgumentException if $element is of the wrong type
addFirst
php
ramsey/collection
src/DoubleEndedQueue.php
https://github.com/ramsey/collection/blob/master/src/DoubleEndedQueue.php
MIT
public function addLast(mixed $element): bool { return $this->add($element); }
@throws InvalidArgumentException if $element is of the wrong type
addLast
php
ramsey/collection
src/DoubleEndedQueue.php
https://github.com/ramsey/collection/blob/master/src/DoubleEndedQueue.php
MIT
public function removeFirst(): mixed { return $this->remove(); }
@return T the first element in this queue. @throws NoSuchElementException if the queue is empty
removeFirst
php
ramsey/collection
src/DoubleEndedQueue.php
https://github.com/ramsey/collection/blob/master/src/DoubleEndedQueue.php
MIT
public function removeLast(): mixed { return $this->pollLast() ?? throw new NoSuchElementException( 'Can\'t return element from Queue. Queue is empty.', ); }
@return T the last element in this queue. @throws NoSuchElementException if this queue is empty.
removeLast
php
ramsey/collection
src/DoubleEndedQueue.php
https://github.com/ramsey/collection/blob/master/src/DoubleEndedQueue.php
MIT
public function pollFirst(): mixed { return $this->poll(); }
@return T | null the head of this queue, or `null` if this queue is empty.
pollFirst
php
ramsey/collection
src/DoubleEndedQueue.php
https://github.com/ramsey/collection/blob/master/src/DoubleEndedQueue.php
MIT
public function pollLast(): mixed { return array_pop($this->data); }
@return T | null the tail of this queue, or `null` if this queue is empty.
pollLast
php
ramsey/collection
src/DoubleEndedQueue.php
https://github.com/ramsey/collection/blob/master/src/DoubleEndedQueue.php
MIT
public function firstElement(): mixed { return $this->element(); }
@return T the head of this queue. @throws NoSuchElementException if this queue is empty.
firstElement
php
ramsey/collection
src/DoubleEndedQueue.php
https://github.com/ramsey/collection/blob/master/src/DoubleEndedQueue.php
MIT
public function lastElement(): mixed { return $this->peekLast() ?? throw new NoSuchElementException( 'Can\'t return element from Queue. Queue is empty.', ); }
@return T the tail of this queue. @throws NoSuchElementException if this queue is empty.
lastElement
php
ramsey/collection
src/DoubleEndedQueue.php
https://github.com/ramsey/collection/blob/master/src/DoubleEndedQueue.php
MIT
public function peekFirst(): mixed { return $this->peek(); }
@return T | null the head of this queue, or `null` if this queue is empty.
peekFirst
php
ramsey/collection
src/DoubleEndedQueue.php
https://github.com/ramsey/collection/blob/master/src/DoubleEndedQueue.php
MIT
public function peekLast(): mixed { $lastIndex = array_key_last($this->data); if ($lastIndex === null) { return null; } return $this->data[$lastIndex]; }
@return T | null the tail of this queue, or `null` if this queue is empty.
peekLast
php
ramsey/collection
src/DoubleEndedQueue.php
https://github.com/ramsey/collection/blob/master/src/DoubleEndedQueue.php
MIT
public function __construct(private readonly string $queueType, array $data = []) { parent::__construct($data); }
Constructs a queue object of the specified type, optionally with the specified data. @param string $queueType The type or class name associated with this queue. @param array<array-key, T> $data The initial items to store in the queue.
__construct
php
ramsey/collection
src/Queue.php
https://github.com/ramsey/collection/blob/master/src/Queue.php
MIT
public function offsetSet(mixed $offset, mixed $value): void { if ($this->checkType($this->getType(), $value) === false) { throw new InvalidArgumentException( 'Value must be of type ' . $this->getType() . '; value is ' . $this->toolValueToString($value), ); } $this->data[] = $value; }
{@inheritDoc} Since arbitrary offsets may not be manipulated in a queue, this method serves only to fulfill the `ArrayAccess` interface requirements. It is invoked by other operations when adding values to the queue. @throws InvalidArgumentException if $value is of the wrong type.
offsetSet
php
ramsey/collection
src/Queue.php
https://github.com/ramsey/collection/blob/master/src/Queue.php
MIT
public function add(mixed $element): bool { $this[] = $element; return true; }
@throws InvalidArgumentException if $value is of the wrong type.
add
php
ramsey/collection
src/Queue.php
https://github.com/ramsey/collection/blob/master/src/Queue.php
MIT
public function element(): mixed { return $this->peek() ?? throw new NoSuchElementException( 'Can\'t return element from Queue. Queue is empty.', ); }
@return T @throws NoSuchElementException if this queue is empty.
element
php
ramsey/collection
src/Queue.php
https://github.com/ramsey/collection/blob/master/src/Queue.php
MIT
public function remove(): mixed { return $this->poll() ?? throw new NoSuchElementException( 'Can\'t return element from Queue. Queue is empty.', ); }
@return T @throws NoSuchElementException if this queue is empty.
remove
php
ramsey/collection
src/Queue.php
https://github.com/ramsey/collection/blob/master/src/Queue.php
MIT
public function __construct(private readonly string $setType, array $data = []) { parent::__construct($data); }
Constructs a set object of the specified type, optionally with the specified data. @param string $setType The type or class name associated with this set. @param array<array-key, T> $data The initial items to store in the set.
__construct
php
ramsey/collection
src/Set.php
https://github.com/ramsey/collection/blob/master/src/Set.php
MIT
public function __construct(array $data = []) { parent::__construct($data); }
@param array<K, T> $data The initial items to add to this map.
__construct
php
ramsey/collection
src/Map/AbstractMap.php
https://github.com/ramsey/collection/blob/master/src/Map/AbstractMap.php
MIT
public function offsetSet(mixed $offset, mixed $value): void { if ($offset === null) { throw new InvalidArgumentException( 'Map elements are key/value pairs; a key must be provided for ' . 'value ' . var_export($value, true), ); } $this->data[$offset] = $value; }
@param K $offset The offset to set @param T $value The value to set at the given offset. @inheritDoc
offsetSet
php
ramsey/collection
src/Map/AbstractMap.php
https://github.com/ramsey/collection/blob/master/src/Map/AbstractMap.php
MIT
public function get(int | string $key, mixed $defaultValue = null): mixed { return $this[$key] ?? $defaultValue; }
@param K $key The key to return from the map. @param T | null $defaultValue The default value to use if `$key` is not found. @return T | null the value or `null` if the key could not be found.
get
php
ramsey/collection
src/Map/AbstractMap.php
https://github.com/ramsey/collection/blob/master/src/Map/AbstractMap.php
MIT
public function put(int | string $key, mixed $value): mixed { $previousValue = $this->get($key); $this[$key] = $value; return $previousValue; }
@param K $key The key to put or replace in the map. @param T $value The value to store at `$key`. @return T | null the previous value associated with key, or `null` if there was no mapping for `$key`.
put
php
ramsey/collection
src/Map/AbstractMap.php
https://github.com/ramsey/collection/blob/master/src/Map/AbstractMap.php
MIT
public function putIfAbsent(int | string $key, mixed $value): mixed { $currentValue = $this->get($key); if ($currentValue === null) { $this[$key] = $value; } return $currentValue; }
@param K $key The key to put in the map. @param T $value The value to store at `$key`. @return T | null the previous value associated with key, or `null` if there was no mapping for `$key`.
putIfAbsent
php
ramsey/collection
src/Map/AbstractMap.php
https://github.com/ramsey/collection/blob/master/src/Map/AbstractMap.php
MIT
public function remove(int | string $key): mixed { $previousValue = $this->get($key); unset($this[$key]); return $previousValue; }
@param K $key The key to remove from the map. @return T | null the previous value associated with key, or `null` if there was no mapping for `$key`.
remove
php
ramsey/collection
src/Map/AbstractMap.php
https://github.com/ramsey/collection/blob/master/src/Map/AbstractMap.php
MIT
public function replace(int | string $key, mixed $value): mixed { $currentValue = $this->get($key); if ($this->containsKey($key)) { $this[$key] = $value; } return $currentValue; }
@param K $key The key to replace. @param T $value The value to set at `$key`. @return T | null the previous value associated with key, or `null` if there was no mapping for `$key`.
replace
php
ramsey/collection
src/Map/AbstractMap.php
https://github.com/ramsey/collection/blob/master/src/Map/AbstractMap.php
MIT
public function __construct(array $namedParameters, array $data = []) { $this->namedParameters = $this->filterNamedParameters($namedParameters); parent::__construct($data); }
Constructs a new `NamedParameterMap`. @param array<array-key, string> $namedParameters The named parameters defined for this map. @param array<string, mixed> $data An initial set of data to set on this map.
__construct
php
ramsey/collection
src/Map/NamedParameterMap.php
https://github.com/ramsey/collection/blob/master/src/Map/NamedParameterMap.php
MIT
public function getNamedParameters(): array { return $this->namedParameters; }
Returns named parameters set for this `NamedParameterMap`. @return array<string, string>
getNamedParameters
php
ramsey/collection
src/Map/NamedParameterMap.php
https://github.com/ramsey/collection/blob/master/src/Map/NamedParameterMap.php
MIT
protected function filterNamedParameters(array $namedParameters): array { $names = []; $types = []; foreach ($namedParameters as $key => $value) { if (is_int($key)) { $names[] = $value; $types[] = 'mixed'; } else { $names[] = $key; $types[] = $value; } } return array_combine($names, $types) ?: []; }
Given an array of named parameters, constructs a proper mapping of named parameters to types. @param array<array-key, string> $namedParameters The named parameters to filter. @return array<string, string>
filterNamedParameters
php
ramsey/collection
src/Map/NamedParameterMap.php
https://github.com/ramsey/collection/blob/master/src/Map/NamedParameterMap.php
MIT
public function __construct( private readonly string $keyType, private readonly string $valueType, array $data = [], ) { parent::__construct($data); }
Constructs a map object of the specified key and value types, optionally with the specified data. @param string $keyType The data type of the map's keys. @param string $valueType The data type of the map's values. @param array<K, T> $data The initial data to set for this map.
__construct
php
ramsey/collection
src/Map/TypedMap.php
https://github.com/ramsey/collection/blob/master/src/Map/TypedMap.php
MIT
protected function checkType(string $type, mixed $value): bool { return match ($type) { 'array' => is_array($value), 'bool', 'boolean' => is_bool($value), 'callable' => is_callable($value), 'float', 'double' => is_float($value), 'int', 'integer' => is_int($value), 'null' => $value === null, 'numeric' => is_numeric($value), 'object' => is_object($value), 'resource' => is_resource($value), 'scalar' => is_scalar($value), 'string' => is_string($value), 'mixed' => true, default => $value instanceof $type, }; }
Returns `true` if value is of the specified type. @param string $type The type to check the value against. @param mixed $value The value to check.
checkType
php
ramsey/collection
src/Tool/TypeTrait.php
https://github.com/ramsey/collection/blob/master/src/Tool/TypeTrait.php
MIT
protected function extractValue(mixed $element, ?string $propertyOrMethod): mixed { if ($propertyOrMethod === null) { return $element; } if (!is_object($element) && !is_array($element)) { throw new UnsupportedOperationException(sprintf( 'The collection type "%s" does not support the $propertyOrMethod parameter', $this->getType(), )); } if (is_array($element)) { return $element[$propertyOrMethod] ?? throw new InvalidPropertyOrMethod(sprintf( 'Key or index "%s" not found in collection elements', $propertyOrMethod, )); } if (property_exists($element, $propertyOrMethod) && method_exists($element, $propertyOrMethod)) { $reflectionProperty = new ReflectionProperty($element, $propertyOrMethod); if ($reflectionProperty->isPublic()) { return $element->$propertyOrMethod; } return $element->{$propertyOrMethod}(); } if (property_exists($element, $propertyOrMethod)) { return $element->$propertyOrMethod; } if (method_exists($element, $propertyOrMethod)) { return $element->{$propertyOrMethod}(); } if (isset($element->$propertyOrMethod)) { return $element->$propertyOrMethod; } throw new InvalidPropertyOrMethod(sprintf( 'Method or property "%s" not defined in %s', $propertyOrMethod, $element::class, )); }
Extracts the value of the given property, method, or array key from the element. If `$propertyOrMethod` is `null`, we return the element as-is. @param mixed $element The element to extract the value from. @param string | null $propertyOrMethod The property or method for which the value should be extracted. @return mixed the value extracted from the specified property, method, or array key, or the element itself. @throws InvalidPropertyOrMethod @throws UnsupportedOperationException
extractValue
php
ramsey/collection
src/Tool/ValueExtractorTrait.php
https://github.com/ramsey/collection/blob/master/src/Tool/ValueExtractorTrait.php
MIT
protected function toolValueToString(mixed $value): string { // null if ($value === null) { return 'NULL'; } // boolean constants if (is_bool($value)) { return $value ? 'TRUE' : 'FALSE'; } // array if (is_array($value)) { return 'Array'; } // scalar types (integer, float, string) if (is_scalar($value)) { return (string) $value; } // resource if (is_resource($value)) { return '(' . get_resource_type($value) . ' resource #' . (int) $value . ')'; } // From here, $value should be an object. assert(is_object($value)); // __toString() is implemented if (is_callable([$value, '__toString'])) { /** @var string */ return $value->__toString(); } // object of type \DateTime if ($value instanceof DateTimeInterface) { return $value->format('c'); } // unknown type return '(' . $value::class . ' Object)'; }
Returns a string representation of the value. - null value: `'NULL'` - boolean: `'TRUE'`, `'FALSE'` - array: `'Array'` - scalar: converted-value - resource: `'(type resource #number)'` - object with `__toString()`: result of `__toString()` - object DateTime: ISO 8601 date - object: `'(className Object)'` - anonymous function: same as object @param mixed $value the value to return as a string.
toolValueToString
php
ramsey/collection
src/Tool/ValueToStringTrait.php
https://github.com/ramsey/collection/blob/master/src/Tool/ValueToStringTrait.php
MIT
public function testOffsetExistsWithNullValue(): void { $genericArrayObject = new GenericArray(); $genericArrayObject['foo'] = null; $this->assertFalse(isset($genericArrayObject['foo'])); }
This serves to ensure that isset() called on the array object for an offset with a NULL value has the same behavior has isset() called on any standard PHP array offset with a NULL value.
testOffsetExistsWithNullValue
php
ramsey/collection
tests/GenericArrayTest.php
https://github.com/ramsey/collection/blob/master/tests/GenericArrayTest.php
MIT
public function testMergingSetsOfObjectsWithKeysAlternate1(): void { $obj1 = new Foo(); $obj2 = new Foo(); $obj3 = new Foo(); $set1 = new Set(Foo::class, ['a' => $obj1, 'b' => $obj2]); $set2 = new Set(Foo::class, ['c' => $obj2, 'd' => $obj3]); $set3 = $set1->merge($set2); $this->assertSame(['a' => $obj1, 'b' => $obj2, 'd' => $obj3], $set3->toArray()); }
Sets don't normally have keys... If a set has keys, when attempting to add a value that a set already contains, even if the key is different, the new value cannot be added because a set cannot contain duplicate values. In this test, the resulting merged set does not contain the "c" key because the set already contains $obj2 when it attempts to add $obj2 again.
testMergingSetsOfObjectsWithKeysAlternate1
php
ramsey/collection
tests/SetTest.php
https://github.com/ramsey/collection/blob/master/tests/SetTest.php
MIT
public function testMergingSetsOfObjectsWithKeysAlternate2(): void { $obj1 = new Foo(); $obj2 = new Foo(); $obj3 = new Foo(); $set1 = new Set(Foo::class, ['a' => $obj1, 'b' => $obj2]); $set2 = new Set(Foo::class, ['c' => $obj2, 'b' => $obj3]); $set3 = $set1->merge($set2); $this->assertSame(['a' => $obj1, 'b' => $obj3], $set3->toArray()); }
Sets don't normally have keys... According to standard array merging rules, later values for the same string keys will overwrite previous ones. This rule is in effect here, but with a set, this can also cause loss of data, depending on the order of the values being merged. In this test, $obj2 does not appear in the merged collection because of the order in which the merging occurs. First, $obj2 is found at key "b." When merging the second set, we see $obj2 at key "c," but we find that our set already contains $obj2, so we don't try to add it again. Then, we merge $obj3 to the key "b," which overwrites $obj2.
testMergingSetsOfObjectsWithKeysAlternate2
php
ramsey/collection
tests/SetTest.php
https://github.com/ramsey/collection/blob/master/tests/SetTest.php
MIT
public function testMergingSetsOfObjectsWithKeysAlternate3(): void { $obj1 = new Foo(); $obj2 = new Foo(); $obj3 = new Foo(); $set1 = new Set(Foo::class, ['a' => $obj1, 'b' => $obj2]); $set2 = new Set(Foo::class, ['b' => $obj3, 'c' => $obj2]); $set3 = $set1->merge($set2); $this->assertSame(['a' => $obj1, 'b' => $obj3, 'c' => $obj2], $set3->toArray()); }
Sets don't normally have keys... This test shows how order can affect behavior when merging. It is very similar to {@see SetTest::testMergingSetsOfObjectsWithKeysAlternate2()}, but $set2 now contains keys "b" and "c" in alphabetical order, so when merging, $obj3 is stored to key "b" and overwrites $obj2 that was previously stored there. When we encounter key "c" (which also has $obj2), this value no longer exists in the merged array, so can add it, and there won't be a duplicate.
testMergingSetsOfObjectsWithKeysAlternate3
php
ramsey/collection
tests/SetTest.php
https://github.com/ramsey/collection/blob/master/tests/SetTest.php
MIT
public function heartbeatUrl(string $url): self { $this->heartbeatUrl = $url; return $this; }
Optional setter. If a consumer of the class calls it, the provided URL will override the default config URL in run().
heartbeatUrl
php
spatie/laravel-health
src/Checks/Checks/HorizonCheck.php
https://github.com/spatie/laravel-health/blob/master/src/Checks/Checks/HorizonCheck.php
MIT
public function headers(array $headers = []): self { $this->headers = $headers; return $this; }
@param array<string, string> $headers @return $this
headers
php
spatie/laravel-health
src/Checks/Checks/PingCheck.php
https://github.com/spatie/laravel-health/blob/master/src/Checks/Checks/PingCheck.php
MIT
public static function fake(array $checks = []): FakeHealth { $fake = (new FakeHealth(static::getFacadeRoot(), $checks)); static::swap($fake); static::swapAlias($fake); return $fake; }
@param array<class-string<Check>, Result|FakeValues|(Closure(Check): Result|FakeValues)> $checks
fake
php
spatie/laravel-health
src/Facades/Health.php
https://github.com/spatie/laravel-health/blob/master/src/Facades/Health.php
MIT
public function save(Collection $checkResults): void { $report = new StoredCheckResults(now()); $checkResults ->map(function (Result $result) { return new StoredCheckResult( name: $result->check->getName(), label: $result->check->getLabel(), notificationMessage: $result->getNotificationMessage(), shortSummary: $result->getShortSummary(), status: (string) $result->status->value, meta: $result->meta, ); }) ->each(function (StoredCheckResult $check) use ($report) { $report->addCheck($check); }); $contents = $report->toJson(); if ($this->disk->exists($this->path)) { $this->disk->delete($this->path); } $this->disk->write($this->path, $contents); }
@param Collection<int, \Spatie\Health\Checks\Result> $checkResults
save
php
spatie/laravel-health
src/ResultStores/JsonFileHealthResultStore.php
https://github.com/spatie/laravel-health/blob/master/src/ResultStores/JsonFileHealthResultStore.php
MIT
public function meta(array $meta): self { $this->meta = $meta; return $this; }
@param array<string, mixed> $meta @return $this
meta
php
spatie/laravel-health
src/ResultStores/StoredCheckResults/StoredCheckResult.php
https://github.com/spatie/laravel-health/blob/master/src/ResultStores/StoredCheckResults/StoredCheckResult.php
MIT
public function containsCheckWithStatus(array|Status $statuses): bool { if ($statuses instanceof Status) { $statuses = [$statuses]; } return $this->storedCheckResults->contains( fn (StoredCheckResult $line) => in_array($line->status, $statuses) ); }
@param array<int, Status>|Status $statuses
containsCheckWithStatus
php
spatie/laravel-health
src/ResultStores/StoredCheckResults/StoredCheckResults.php
https://github.com/spatie/laravel-health/blob/master/src/ResultStores/StoredCheckResults/StoredCheckResults.php
MIT
public function __construct(array $checks) { parent::__construct($checks); }
@param array<int, \Spatie\Health\Checks\Check> $checks
__construct
php
spatie/laravel-health
src/Support/Checks.php
https://github.com/spatie/laravel-health/blob/master/src/Support/Checks.php
MIT
public function __construct( private Health $decoratedHealth, private array $fakeChecks ) {}
@param array<class-string<Check>, Result|FakeValues|(Closure(Check): Result|FakeValues)> $fakeChecks
__construct
php
spatie/laravel-health
src/Testing/FakeHealth.php
https://github.com/spatie/laravel-health/blob/master/src/Testing/FakeHealth.php
MIT
protected function buildFakeCheck(Check $decoratedCheck, Result|FakeValues|Closure $result): FakeCheck { // @phpstan-ignore-next-line $result = FakeValues::from(value($result, $decoratedCheck)); return FakeCheck::new()->fake($decoratedCheck, $result); }
@param Result|FakeValues|(Closure(Check): Result|FakeValues) $result
buildFakeCheck
php
spatie/laravel-health
src/Testing/FakeHealth.php
https://github.com/spatie/laravel-health/blob/master/src/Testing/FakeHealth.php
MIT
public function make($pathToFile, $type = 'zip') { $new = $this->createArchiveFile($pathToFile); $objectOrName = $type; if (is_string($type)) { $objectOrName = 'Chumper\Zipper\Repositories\\' . ucwords($type) . 'Repository'; } if (!is_subclass_of($objectOrName, 'Chumper\Zipper\Repositories\RepositoryInterface')) { throw new \InvalidArgumentException("Class for '{$objectOrName}' must implement RepositoryInterface interface"); } try { if (is_string($objectOrName)) { $this->repository = new $objectOrName($pathToFile, $new); } else { $this->repository = $type; } } catch(Exception $e) { throw $e; } $this->filePath = $pathToFile; return $this; }
Create a new zip Archive if the file does not exists opens a zip archive if the file exists @param $pathToFile string The file to open @param RepositoryInterface|string $type The type of the archive, defaults to zip, possible are zip, phar @throws \RuntimeException @throws \Exception @throws \InvalidArgumentException @return $this Zipper instance
make
php
Chumper/Zipper
src/Chumper/Zipper/Zipper.php
https://github.com/Chumper/Zipper/blob/master/src/Chumper/Zipper/Zipper.php
Apache-2.0
public function zip($pathToFile) { $this->make($pathToFile); return $this; }
Create a new zip archive or open an existing one @param $pathToFile @throws \Exception @return $this
zip
php
Chumper/Zipper
src/Chumper/Zipper/Zipper.php
https://github.com/Chumper/Zipper/blob/master/src/Chumper/Zipper/Zipper.php
Apache-2.0
public function phar($pathToFile) { $this->make($pathToFile, 'phar'); return $this; }
Create a new phar file or open one @param $pathToFile @throws \Exception @return $this
phar
php
Chumper/Zipper
src/Chumper/Zipper/Zipper.php
https://github.com/Chumper/Zipper/blob/master/src/Chumper/Zipper/Zipper.php
Apache-2.0
public function rar($pathToFile) { $this->make($pathToFile, 'rar'); return $this; }
Create a new rar file or open one @param $pathToFile @throws \Exception @return $this
rar
php
Chumper/Zipper
src/Chumper/Zipper/Zipper.php
https://github.com/Chumper/Zipper/blob/master/src/Chumper/Zipper/Zipper.php
Apache-2.0
public function extractTo($path, array $files = [], $methodFlags = self::BLACKLIST) { if (!$this->file->exists($path) && !$this->file->makeDirectory($path, 0755, true)) { throw new \RuntimeException('Failed to create folder'); } if ($methodFlags & self::EXACT_MATCH) { $matchingMethod = function ($haystack) use ($files) { return in_array($haystack, $files, true); }; } else { $matchingMethod = function ($haystack) use ($files) { return starts_with($haystack, $files); }; } if ($methodFlags & self::WHITELIST) { $this->extractFilesInternal($path, $matchingMethod); } else { // blacklist - extract files that do not match with $matchingMethod $this->extractFilesInternal($path, function ($filename) use ($matchingMethod) { return !$matchingMethod($filename); }); } }
Extracts the opened zip archive to the specified location <br/> you can provide an array of files and folders and define if they should be a white list or a black list to extract. By default this method compares file names using "string starts with" logic @param $path string The path to extract to @param array $files An array of files @param int $methodFlags The Method the files should be treated @throws \Exception
extractTo
php
Chumper/Zipper
src/Chumper/Zipper/Zipper.php
https://github.com/Chumper/Zipper/blob/master/src/Chumper/Zipper/Zipper.php
Apache-2.0
public function extractMatchingRegex($extractToPath, $regex) { if (empty($regex)) { throw new \InvalidArgumentException('Missing pass valid regex parameter'); } $this->extractFilesInternal($extractToPath, function ($filename) use ($regex) { $match = preg_match($regex, $filename); if ($match === 1) { return true; } elseif ($match === false) { //invalid pattern for preg_match raises E_WARNING and returns FALSE //so if you have custom error_handler set to catch and throw E_WARNINGs you never end up here //but if you have not - this will throw exception throw new \RuntimeException("regular expression match on '$filename' failed with error. Please check if pattern is valid regular expression."); } return false; }); }
Extracts matching files/folders from the opened zip archive to the specified location. @param string $extractToPath The path to extract to @param string $regex regular expression used to match files. See @link http://php.net/manual/en/reference.pcre.pattern.syntax.php @throws \InvalidArgumentException @throws \RuntimeException
extractMatchingRegex
php
Chumper/Zipper
src/Chumper/Zipper/Zipper.php
https://github.com/Chumper/Zipper/blob/master/src/Chumper/Zipper/Zipper.php
Apache-2.0
public function getFileContent($filePath) { if ($this->repository->fileExists($filePath) === false) { throw new Exception(sprintf('The file "%s" cannot be found', $filePath)); } return $this->repository->getFileContent($filePath); }
Gets the content of a single file if available @param $filePath string The full path (including all folders) of the file in the zip @throws \Exception @return mixed returns the content or throws an exception
getFileContent
php
Chumper/Zipper
src/Chumper/Zipper/Zipper.php
https://github.com/Chumper/Zipper/blob/master/src/Chumper/Zipper/Zipper.php
Apache-2.0
public function add($pathToAdd, $fileName = null) { if (is_array($pathToAdd)) { foreach ($pathToAdd as $key=>$dir) { if (!is_int($key)) { $this->add($dir, $key); } else { $this->add($dir); } } } elseif ($this->file->isFile($pathToAdd)) { if ($fileName) { $this->addFile($pathToAdd, $fileName); } else { $this->addFile($pathToAdd); } } else { $this->addDir($pathToAdd); } return $this; }
Add one or multiple files to the zip. @param $pathToAdd array|string An array or string of files and folders to add @param null|mixed $fileName @return $this Zipper instance
add
php
Chumper/Zipper
src/Chumper/Zipper/Zipper.php
https://github.com/Chumper/Zipper/blob/master/src/Chumper/Zipper/Zipper.php
Apache-2.0
public function addEmptyDir($dirName) { $this->repository->addEmptyDir($dirName); return $this; }
Add an empty directory @param $dirName @return Zipper
addEmptyDir
php
Chumper/Zipper
src/Chumper/Zipper/Zipper.php
https://github.com/Chumper/Zipper/blob/master/src/Chumper/Zipper/Zipper.php
Apache-2.0
public function addString($filename, $content) { $this->addFromString($filename, $content); return $this; }
Add a file to the zip using its contents @param $filename string The name of the file to create @param $content string The file contents @return $this Zipper instance
addString
php
Chumper/Zipper
src/Chumper/Zipper/Zipper.php
https://github.com/Chumper/Zipper/blob/master/src/Chumper/Zipper/Zipper.php
Apache-2.0
public function getStatus() { return $this->repository->getStatus(); }
Gets the status of the zip. @return int The status of the internal zip file
getStatus
php
Chumper/Zipper
src/Chumper/Zipper/Zipper.php
https://github.com/Chumper/Zipper/blob/master/src/Chumper/Zipper/Zipper.php
Apache-2.0
public function remove($fileToRemove) { if (is_array($fileToRemove)) { $self = $this; $this->repository->each(function ($file) use ($fileToRemove, $self) { if (starts_with($file, $fileToRemove)) { $self->getRepository()->removeFile($file); } }); } else { $this->repository->removeFile($fileToRemove); } return $this; }
Remove a file or array of files and folders from the zip archive @param $fileToRemove array|string The path/array to the files in the zip @return $this Zipper instance
remove
php
Chumper/Zipper
src/Chumper/Zipper/Zipper.php
https://github.com/Chumper/Zipper/blob/master/src/Chumper/Zipper/Zipper.php
Apache-2.0
public function getFilePath() { return $this->filePath; }
Returns the path of the current zip file if there is one. @return string The path to the file
getFilePath
php
Chumper/Zipper
src/Chumper/Zipper/Zipper.php
https://github.com/Chumper/Zipper/blob/master/src/Chumper/Zipper/Zipper.php
Apache-2.0
public function usePassword($password) { return $this->repository->usePassword($password); }
Sets the password to be used for decompressing @param $password @return bool
usePassword
php
Chumper/Zipper
src/Chumper/Zipper/Zipper.php
https://github.com/Chumper/Zipper/blob/master/src/Chumper/Zipper/Zipper.php
Apache-2.0
public function close() { if (null !== $this->repository) { $this->repository->close(); } $this->filePath = ''; }
Closes the zip file and frees all handles
close
php
Chumper/Zipper
src/Chumper/Zipper/Zipper.php
https://github.com/Chumper/Zipper/blob/master/src/Chumper/Zipper/Zipper.php
Apache-2.0