<?php namespace Illuminate\Tests\Support; use stdClass; use ArrayAccess; use Mockery as m; use ReflectionClass; use JsonSerializable; use PHPUnit\Framework\TestCase; use Illuminate\Support\Collection; use Illuminate\Contracts\Support\Jsonable; use Illuminate\Contracts\Support\Arrayable; class SupportCollectionTest extends TestCase { public function testFirstReturnsFirstItemInCollection() { $c = new Collection(['foo', 'bar']); $this->assertEquals('foo', $c->first()); } public function testFirstWithCallback() { $data = new Collection(['foo', 'bar', 'baz']); $result = $data->first(function ($value) { return $value === 'bar'; }); $this->assertEquals('bar', $result); }
PHP's Laravel collection library is a library for obtaining a collection. A collection is equivalent to a table.
All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn
Related Article
29Jul2016
:This article mainly introduces the collection of PHP libraries. Students who are interested in PHP tutorials can refer to it.
30Sep2016
Looking for a php/python library management program (similar to Baidu library, managing doc/pdf and other libraries)~~ It mainly needs to have search functions, especially file classification retrieval/file tag retrieval functions, no need for online conversion, online browsing!
15Jun2023
In development projects, the use of PHP function libraries is very extensive. With the continuous maintenance of the project, the maintenance and management of PHP function libraries have become more and more important. This article will introduce some practical methods of PHP function library maintenance to help project developers better manage and maintain function libraries. 1. Standardized naming Standardized naming of each function in the function library can make the function library easier to use and manage. When naming functions, try to use meaningful words and follow the following conventions: 1. Function names should use lowercase letters and the following
06Jul2016
I have seen many open source projects in the form of class.classname.php, but I have also seen many frameworks in the form of classname.class.php. Where should I place this class? I personally prefer the .class.php form, because in some frameworks, after importing third-party class libraries and specifying class libraries...
09Jul2023
PHP client library recommendations and usage instructions for the MQTT protocol MQTT (MessageQueuingTelemetryTransport) is a lightweight message transmission protocol that is widely used in fields such as the Internet of Things and sensor networks. In PHP development, in order to facilitate communication with the MQTT server using the MQTT protocol, we can choose to use some PHP client libraries to simplify this process. In this article, we will recommend several commonly used PHP client libraries and provide usage instructions.
14Jul2023
Tips for generating colorful verification code images using PHP and GD libraries Introduction: Verification code is a common network security technology. By requiring users to enter a verification code when logging in, registering, or submitting a form, you can effectively prevent automated attacks from robots and malicious programs. This article will introduce the techniques of using PHP and GD libraries to generate colorful verification code images, helping developers to add a certain degree of recognizability and artistry when creating verification codes. 1. Environment preparation Before starting, make sure that PHP and GD libraries have been installed in your development environment. Can
Hot Tools
PHP library for dependency injection containers
PHP library for dependency injection containers
A collection of 50 excellent classic PHP algorithms
Classic PHP algorithm, learn excellent ideas and expand your thinking
Small PHP library for optimizing images
Small PHP library for optimizing images