Server IP : 127.0.0.2 / Your IP : 3.148.252.90 Web Server : Apache/2.4.18 (Ubuntu) System : User : www-data ( ) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/ |
Upload File : |
<?php namespace Hamcrest\Core; /* Copyright (c) 2010 hamcrest.org */ use Hamcrest\BaseMatcher; use Hamcrest\Description; /** * Tests if a value (class, object, or array) has a named property. * * For example: * <pre> * assertThat(array('a', 'b'), set('b')); * assertThat($foo, set('bar')); * assertThat('Server', notSet('defaultPort')); * </pre> * * @todo Replace $property with a matcher and iterate all property names. */ class Set extends BaseMatcher { private $_property; private $_not; public function __construct($property, $not = false) { $this->_property = $property; $this->_not = $not; } public function matches($item) { if ($item === null) { return false; } $property = $this->_property; if (is_array($item)) { $result = isset($item[$property]); } elseif (is_object($item)) { $result = isset($item->$property); } elseif (is_string($item)) { $result = isset($item::$$property); } else { throw new \InvalidArgumentException('Must pass an object, array, or class name'); } return $this->_not ? !$result : $result; } public function describeTo(Description $description) { $description->appendText($this->_not ? 'unset property ' : 'set property ')->appendText($this->_property); } public function describeMismatch($item, Description $description) { $value = ''; if (!$this->_not) { $description->appendText('was not set'); } else { $property = $this->_property; if (is_array($item)) { $value = $item[$property]; } elseif (is_object($item)) { $value = $item->$property; } elseif (is_string($item)) { $value = $item::$$property; } parent::describeMismatch($value, $description); } } /** * Matches if value (class, object, or array) has named $property. * * @factory */ public static function set($property) { return new self($property); } /** * Matches if value (class, object, or array) does not have named $property. * * @factory */ public static function notSet($property) { return new self($property, true); } }