idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
9,900 | public static function fromString ( $ str , $ directory = null ) { return new self ( ( new fphp \ Helper \ XmlParser ( ) ) -> parseString ( $ str ) ) ; } | Creates an XML configuration from an XML string . |
9,901 | protected function prepareDateTime ( $ value ) { if ( $ this -> requireAppTimeZone && ! static :: timeZoneEqual ( $ value -> getTimeZone ( ) , $ this -> appTimeZone ) ) { throw new \ UnexpectedValueException ( "Incoming time zone {$value->getTimeZone()->getName()} did not match app time zone {$this->appTimeZone->getNam... | Don t type hint here - there s no common interface between DateTime and DateTimeImmutable at 5 . 6 that supports all the methods we are using though both objects remain largely interchangeable . |
9,902 | protected function is ( $ methodName ) { if ( ! method_exists ( $ this , $ methodName ) ) { throw new TextParserException ( "The method `$methodName` does not exist" ) ; } if ( ! is_callable ( array ( $ this , $ methodName ) ) ) { throw new TextParserException ( "The method `$methodName` is inaccessible" ) ; } $ offset... | Does the next thing satisfies a given method? |
9,903 | public function getControllerName ( ) { if ( empty ( $ this -> controller_name ) ) { $ controller_class = get_class ( $ this ) ; if ( ( $ pos = strrpos ( $ controller_class , '\\' ) ) !== false ) { $ this -> controller_name = substr ( $ controller_class , $ pos + 1 ) ; } else { $ this -> controller_name = $ controller_... | Return controller name without namespace . |
9,904 | protected function getParsedBodyParam ( ServerRequestInterface $ request , $ param_name , $ default = null ) { $ parsed_body = $ request -> getParsedBody ( ) ; if ( $ parsed_body ) { if ( is_array ( $ parsed_body ) && array_key_exists ( $ param_name , $ parsed_body ) ) { return $ parsed_body [ $ param_name ] ; } elseif... | Return a param from a parsed body . |
9,905 | function tzinfo ( $ zone ) { $ ref = new DateTimeZone ( $ zone ) ; $ loc = $ ref -> getLocation ( ) ; $ trn = $ ref -> getTransitions ( $ now = time ( ) , $ now ) ; $ out = array ( 'offset' => $ ref -> getOffset ( new DateTime ( 'now' , new DateTimeZone ( 'GMT' ) ) ) / 3600 , 'country' => $ loc [ 'country_code' ] , 'la... | Return information about specified Unix time zone |
9,906 | public function login ( ) { if ( $ this -> getGet ( 'code' ) ) { $ this -> client -> authenticate ( $ this -> getGet ( 'code' ) ) ; $ this -> setSession ( 'token' , $ this -> client -> getAccessToken ( ) ) ; $ redirect = $ this -> config -> redirect_uris [ 0 ] ; header ( 'Location: ' . filter_var ( $ redirect , FILTER_... | Logs in the user |
9,907 | public function countSelectors ( $ css = null ) { $ count = 0 ; if ( $ css !== null && $ this -> css !== $ css ) { $ this -> css = $ css ; $ this -> parsedCss = $ this -> splitIntoBlocks ( $ this -> css ) ; } foreach ( $ this -> parsedCss as $ rules ) { $ count += $ rules [ 'count' ] ; } return $ count ; } | Counts the selectors in the given css |
9,908 | public function split ( $ css = null , $ part = 1 , $ maxSelectors = self :: MAX_SELECTORS_DEFAULT ) { if ( empty ( $ css ) && empty ( $ this -> css ) ) { return null ; } if ( ! empty ( $ css ) && $ this -> css !== $ css ) { $ this -> css = $ css ; } $ charset = $ this -> extractCharset ( $ this -> css ) ; isset ( $ ch... | Returns the requested part of the split css |
9,909 | private function summarizeBlock ( $ block ) { $ block = array ( 'rules' => is_array ( $ block ) ? $ block : $ this -> splitIntoRules ( trim ( $ block ) ) , 'count' => 0 ) ; foreach ( $ block [ 'rules' ] as $ key => $ rule ) { $ block [ 'rules' ] [ $ key ] = array ( 'rule' => $ rule , 'count' => $ this -> countSelectors... | Summarizes the block of CSS |
9,910 | private function splitIntoBlocks ( $ css ) { if ( is_array ( $ css ) ) { return $ css ; } $ blocks = array ( ) ; $ css = $ this -> stripComments ( $ css ) ; $ offset = 0 ; if ( preg_match_all ( '/(@[^{]+){([^{}]*{[^}]*})*\s*}/ism' , $ css , $ matches , PREG_OFFSET_CAPTURE ) > 0 ) { foreach ( $ matches [ 0 ] as $ key =>... | Splits the css into blocks maintaining the order of the rules and media queries |
9,911 | private function splitIntoRules ( $ css ) { $ rules = preg_split ( '/}/' , trim ( $ this -> stripComments ( $ css ) ) ) ; array_walk ( $ rules , function ( & $ s ) { ! empty ( $ s ) && $ s = trim ( "$s}" ) ; } ) ; return array_filter ( $ rules ) ; } | Splits the css into it s rules |
9,912 | public static function describeTable ( AdapterInterface $ db , $ table , $ schema = null ) { $ columns = $ db -> describeColumns ( $ table , $ schema ) ; $ indexes = $ db -> describeIndexes ( $ table , $ schema ) ; $ references = $ db -> describeReferences ( $ table , $ schema ) ; $ options = $ db -> tableOptions ( $ t... | Gets table description |
9,913 | static public function validate ( ezcDbSchema $ schema ) { $ errors = array ( ) ; foreach ( $ schema -> getSchema ( ) as $ tableName => $ table ) { $ fields = array_keys ( $ table -> fields ) ; foreach ( $ table -> indexes as $ indexName => $ index ) { foreach ( $ index -> indexFields as $ indexFieldName => $ dummy ) {... | Validates if all the fields used in all indexes exist . |
9,914 | public function prepend ( $ message ) { $ this -> log = [ $ message ] + $ this -> log ; $ this -> extendedLog = [ $ message ] + $ this -> extendedLog ; } | Prepend a message to the log |
9,915 | public static function getExtensions ( string $ mime ) : array { $ extensions = [ ] ; foreach ( static :: $ _types as $ extension => $ mimeType ) { if ( $ mimeType === $ mime ) { $ extensions [ ] = $ extension ; } } return $ extensions ; } | Get extensions for one mime |
9,916 | protected function onSetAttribute ( $ name , $ value ) { $ listen = [ 'message_type' => 'type' , 'message_id' => 'id' , 'credits_cost' => 'credits' , 'rb_cost' => 'cost' , ] ; if ( isset ( $ listen [ $ name ] ) ) { if ( ! isset ( $ this -> { $ listen [ $ name ] } ) ) { $ this -> { $ listen [ $ name ] } = $ value ; } } ... | When an attribute is set |
9,917 | public function delete_cache ( $ command_name = '' , $ arguments = false ) { $ uid = $ this -> hostname ; if ( ! empty ( $ arguments ) ) { $ uid .= md5 ( json_encode ( $ arguments ) ) ; } if ( ! empty ( $ this -> cache_delete ( $ uid , $ command_name ) ) ) { \ bbn \ x :: log ( [ $ uid , $ command_name ] , 'cache_delete... | This function allows the cancellation of the cache of the used commands |
9,918 | private function get_header_url ( ) { return "wget -O - --quiet --http-user=" . $ this -> user . " --http-passwd=" . escapeshellarg ( $ this -> pass ) . " --no-check-certificate 'https://" . $ this -> hostname . ":10000/" . ( $ this -> mode === 'cloudmin' ? 'server-manager' : 'virtual-server' ) . "/remote.cgi?json=1&mu... | This function is used to get the header url part to be executed |
9,919 | protected function createUrl ( BlockadeException $ exception , Request $ request ) { if ( $ exception instanceof AuthenticationException || $ exception instanceof CredentialsException ) { return $ this -> login_url . '/to' . $ request -> getPathInfo ( ) ; } return $ this -> deny_url ; } | Create the url to redirect to . |
9,920 | protected function createXmlHttpResponse ( BlockadeException $ exception , Request $ request ) { if ( $ exception instanceof AuthenticationException || $ exception instanceof CredentialsException ) { return new Response ( 'Authentication required' , Response :: HTTP_UNAUTHORIZED ) ; } return new Response ( 'Access deni... | Create a response for XmlHttpRequests . |
9,921 | public function call ( $ function , array $ parameters = [ ] ) { $ inspector = new ReflectionFunction ( $ function ) ; $ dependencies = $ inspector -> getParameters ( ) ; $ dependencies = $ this -> process ( '' , $ parameters , $ dependencies ) ; return call_user_func_array ( $ function , $ dependencies ) ; } | Call a user function injecting the dependencies . |
9,922 | public function make ( string $ abstract , array $ parameters = [ ] ) { try { if ( ! isset ( $ this -> resolving [ $ abstract ] ) ) { $ this -> resolving [ $ abstract ] = $ this -> construct ( $ abstract ) ; } return $ this -> resolving [ $ abstract ] ( $ abstract , $ parameters ) ; } catch ( ReflectionException $ e ) ... | Makes an element or class injecting automatically all the dependencies . |
9,923 | protected function construct ( string $ abstract ) : Closure { $ inspector = new ReflectionClass ( $ abstract ) ; if ( ( $ constructor = $ inspector -> getConstructor ( ) ) && ( $ dependencies = $ constructor -> getParameters ( ) ) ) { return function ( string $ abstract , array $ parameters ) use ( $ inspector , $ dep... | Construct a class and all the dependencies using the reflection library of PHP . |
9,924 | protected function process ( string $ abstract , array $ parameters , array $ dependencies ) : array { foreach ( $ dependencies as & $ dependency ) { if ( isset ( $ parameters [ $ dependency -> name ] ) ) { $ dependency = $ parameters [ $ dependency -> name ] ; } else $ dependency = $ this -> resolve ( $ abstract , $ d... | Process all dependencies |
9,925 | protected function resolve ( string $ abstract , ReflectionParameter $ dependency ) { $ key = $ abstract . $ dependency -> name ; if ( ! isset ( $ this -> resolved [ $ key ] ) ) { $ this -> resolved [ $ key ] = $ this -> generate ( $ abstract , $ dependency ) ; } return $ this -> resolved [ $ key ] ( $ this ) ; } | Resolve all the given class reflected dependencies . |
9,926 | protected function generate ( string $ abstract , ReflectionParameter $ dependency ) : Closure { if ( $ class = $ dependency -> getClass ( ) ) { return $ this -> build ( $ class -> name , "{$abstract}{$class->name}" ) ; } try { $ value = $ dependency -> getDefaultValue ( ) ; return function ( ) use ( $ value ) { return... | Generate the dependencies callbacks to jump some conditions in every dependency creation . |
9,927 | protected function build ( string $ classname , string $ entry ) : Closure { if ( isset ( $ this -> dependencies [ $ entry ] ) ) { return $ this -> dependencies [ $ entry ] ; } return function ( ) use ( $ classname ) { return $ this -> make ( $ classname ) ; } ; } | Create a build closure for a given class |
9,928 | public function flush ( ) : ContainerInterface { $ this -> collection = [ ] ; $ this -> dependencies = [ ] ; $ this -> resolving = [ ] ; $ this -> resolved = [ ] ; return $ this ; } | Reset the container removing all the elements cache and options . |
9,929 | public function isSingleton ( string $ abstract ) : bool { if ( ! $ this -> has ( $ abstract ) ) { throw new NotFoundException ( "Element '$abstract' not found" ) ; } return $ this -> collection [ $ abstract ] instanceof Closure === false ; } | Verify if an element has a singleton instance . |
9,930 | public function set ( string $ abstract , $ concrete , bool $ shared = false ) : ContainerInterface { if ( is_object ( $ concrete ) ) { return $ this -> instance ( $ abstract , $ concrete ) ; } if ( $ concrete instanceof Closure === false ) { $ concrete = function ( Container $ container ) use ( $ concrete ) { return $... | Bind a new element to the container . |
9,931 | public function setIf ( string $ abstract , $ concrete , bool $ shared = false ) : ContainerInterface { if ( ! $ this -> has ( $ abstract ) ) { $ this -> set ( $ abstract , $ concrete , $ shared ) ; } return $ this ; } | Bind a new element to the container IF the element name not exists in the container . |
9,932 | public function setTo ( string $ class , string $ dependencyName , $ dependency ) : ContainerInterface { $ key = "$class$dependencyName" ; if ( $ dependency instanceof Closure === false ) { $ this -> set ( $ key , $ dependency ) ; $ resolved = $ this -> collection [ $ key ] ; $ dependency = function ( ) use ( $ resolve... | Bind an specific instance to a class dependency . |
9,933 | public function instance ( string $ abstract , $ instance ) : ContainerInterface { if ( ! is_object ( $ instance ) ) { throw new ContainerException ( 'Trying to store ' . gettype ( $ instance ) . ' as object.' ) ; } $ this -> collection [ $ abstract ] = $ instance ; return $ this ; } | Bind an object to the container . |
9,934 | public function extend ( string $ abstract , closure $ extension ) : ContainerInterface { $ object = $ this -> get ( $ abstract ) ; $ this -> collection [ $ abstract ] = $ extension ( $ object , $ this ) ; return $ this ; } | Modify an element with a given function that receive the old element as argument . |
9,935 | public function share ( string $ abstract ) : ContainerInterface { $ object = $ this -> get ( $ abstract ) ; $ this -> collection [ $ abstract ] = $ object ; return $ this ; } | Makes an resolvable element an singleton . |
9,936 | public function start ( $ key = 'default' ) { if ( ! isset ( $ this -> measures [ $ key ] ) ) { $ this -> measures [ $ key ] = [ 'num' => 0 , 'sum' => 0 , 'start' => microtime ( 1 ) ] ; } else { $ this -> measures [ $ key ] [ 'start' ] = microtime ( 1 ) ; } } | Starts a timer for a given key |
9,937 | public function has_started ( $ key ) { if ( isset ( $ this -> measures [ $ key ] ) ) { return $ this -> measures [ $ key ] [ 'start' ] > 0 ; } return false ; } | Returns true is the timer has started for the given key |
9,938 | public function stop ( $ key = 'default' ) { if ( isset ( $ this -> measures [ $ key ] , $ this -> measures [ $ key ] [ 'start' ] ) ) { $ this -> measures [ $ key ] [ 'num' ] ++ ; $ time = $ this -> measure ( $ key ) ; $ this -> measures [ $ key ] [ 'sum' ] += $ time ; unset ( $ this -> measures [ $ key ] [ 'start' ] )... | Stops a timer for a given key |
9,939 | protected function getArrayAbleAppends ( ) { if ( property_exists ( $ this , 'customAppends' ) ) { if ( is_array ( self :: $ customAppends ) && count ( self :: $ customAppends ) ) return self :: $ customAppends ; elseif ( is_bool ( self :: $ customAppends ) && ! self :: $ customAppends ) return [ ] ; } return parent ::... | Append attribute ignore |
9,940 | public function get ( string $ id ) : ? array { $ mask = $ this -> db -> rselect ( 'bbn_notes_masks' , [ ] , [ 'id_note' => $ id ] ) ; if ( $ data = $ this -> notes -> get ( $ mask [ 'id_note' ] ) ) { $ data [ 'default' ] = $ mask [ 'def' ] ; $ data [ 'id_type' ] = $ mask [ 'id_type' ] ; $ data [ 'type' ] = $ this -> o... | Gets the content of a mask based on the provided ID |
9,941 | private function getDatetime ( $ datein , $ timein ) { $ date = explode ( '-' , $ datein ) ; $ time = explode ( ':' , $ timein ) ; $ datetime = Carbon :: create ( $ date [ 0 ] , $ date [ 1 ] , $ date [ 2 ] , $ time [ 0 ] , $ time [ 1 ] ) ; return $ datetime ; } | Get Carbon start datetime and end datemime . |
9,942 | public function confirmDestroy ( Request $ request , Event $ event ) { $ this -> authorize ( 'delete' , $ event ) ; return view ( 'laralum::pages.confirmation' , [ 'method' => 'DELETE' , 'message' => __ ( 'laralum_events::general.sure_del_event' , [ 'event' => $ event -> title ] ) , 'action' => route ( 'laralum::events... | confirm destroy of the specified resource from storage . |
9,943 | public function join ( Event $ event ) { $ this -> authorize ( 'join' , Event :: class ) ; $ event -> addUser ( User :: findOrfail ( Auth :: id ( ) ) ) ; return redirect ( ) -> route ( 'laralum::events.index' ) -> with ( 'success' , __ ( 'laralum_events::general.joined_event' , [ 'id' => $ event -> id ] ) ) ; } | Join to the specified resource from storage . |
9,944 | public function leave ( Event $ event ) { $ this -> authorize ( 'join' , Event :: class ) ; $ event -> deleteUser ( User :: findOrfail ( Auth :: id ( ) ) ) ; return redirect ( ) -> route ( 'laralum::events.index' ) -> with ( 'success' , __ ( 'laralum_events::general.left_event' , [ 'id' => $ event -> id ] ) ) ; } | Leave from the specified resource from storage . |
9,945 | public function makeResponsible ( Event $ event , User $ user ) { $ this -> authorize ( 'update' , $ event ) ; $ event -> addResponsible ( $ user ) ; return redirect ( ) -> route ( 'laralum::events.show' , [ 'event' => $ event -> id ] ) -> with ( 'success' , __ ( 'laralum_events::general.responsible_added' , [ 'event_i... | Make author of to the specified resource from storage . |
9,946 | public function undoResponsible ( Event $ event , User $ user ) { $ this -> authorize ( 'update' , $ event ) ; $ event -> deleteResponsible ( $ user ) ; return redirect ( ) -> route ( 'laralum::events.show' , [ 'event' => $ event -> id ] ) -> with ( 'success' , __ ( 'laralum_events::general.responsible_deleted' , [ 'ev... | Undo author from the specified resource from storage . |
9,947 | protected function createStream ( BrowserKitRequest $ request ) { $ stream = fopen ( 'php://temp' , 'a+' ) ; fwrite ( $ stream , $ request -> getContent ( ) ) ; return new Stream ( $ stream ) ; } | Create the output stream handle |
9,948 | protected function buildFullUri ( BrowserKitRequest $ request ) { $ uri = new Uri ( $ request -> getUri ( ) ) ; $ queryParams = [ ] ; parse_str ( $ uri -> getQuery ( ) , $ queryParams ) ; if ( $ request -> getMethod ( ) === 'GET' ) { $ queryParams = array_merge ( $ queryParams , $ request -> getParameters ( ) ) ; $ uri... | Build a full URI from a request |
9,949 | protected function setRequestHeaders ( ServerRequestInterface $ baseRequest , array $ params ) { $ headers = ( new ServerRequest ( ) ) -> withServerParams ( $ params ) -> getHeaders ( ) ; $ psrRequest = $ baseRequest ; foreach ( $ headers as $ header => $ values ) { $ psrRequest = $ psrRequest -> withHeader ( $ header ... | Set the request headers |
9,950 | protected function setRequestProperties ( ServerRequestInterface $ baseRequest , BrowserKitRequest $ request , Stream $ stream , UriInterface $ uri , array $ queryParams ) { return $ baseRequest -> withProtocolVersion ( '1.1' ) -> withBody ( $ stream ) -> withMethod ( $ request -> getMethod ( ) ) -> withRequestTarget (... | Set the server request properties |
9,951 | protected function convertUploadedFiles ( array $ files ) { $ fileObjects = [ ] ; foreach ( $ files as $ fieldName => $ file ) { if ( $ file instanceof UploadedFileInterface ) { $ fileObjects [ $ fieldName ] = $ file ; } elseif ( ! isset ( $ file [ 'tmp_name' ] ) && ! isset ( $ file [ 'error' ] ) ) { $ fileObjects [ $ ... | Convert a list of uploaded files to a Jasny PSR - 7 uploaded files |
9,952 | public function convert ( BrowserKitRequest $ request , ServerRequestInterface $ baseRequest ) { $ stream = $ this -> createStream ( $ request ) ; list ( $ uri , $ queryParams ) = $ this -> buildFullUri ( $ request ) ; if ( $ baseRequest instanceof ServerRequest ) { $ serverParams = $ this -> determineServerParams ( $ ... | Convert a codeception request to a PSR - 7 server request |
9,953 | public static function toArray ( $ e , $ getTrace = true , $ catcher = null ) { $ data = [ 'class' => \ get_class ( $ e ) , 'message' => $ e -> getMessage ( ) , 'code' => $ e -> getCode ( ) , 'file' => $ e -> getFile ( ) . ':' . $ e -> getLine ( ) , ] ; if ( $ catcher ) { $ data [ 'catcher' ] = $ catcher ; } if ( $ get... | Converts an exception into a simple array . |
9,954 | protected function supportedType ( $ type ) { $ supportedType = false ; $ baseType = substr ( $ type , 0 , strpos ( $ type , '-' ) ) ; if ( array_key_exists ( $ baseType , $ this -> supportedTypes ) ) { $ supportedType = $ baseType ; } return $ supportedType ; } | Find the matching installer type |
9,955 | protected function dbConnect ( array $ aOptions ) { $ aOptions = array_merge ( SudoBible :: DB_CREDS , $ aOptions ) ; try { $ this -> db = new mysqli ( $ aOptions [ 'db_host' ] , $ aOptions [ 'db_user' ] , $ aOptions [ 'db_pass' ] , $ aOptions [ 'db_name' ] , $ aOptions [ 'db_port' ] ) ; } catch ( Exception $ e ) { thr... | Connect to the DB . |
9,956 | public function setTranslation ( $ mTranslation ) { $ this -> iTranslation = is_numeric ( $ mTranslation ) ? $ mTranslation : $ this -> getIdFor ( 'translation' , $ mTranslation ) ; } | Set the translation preference . |
9,957 | protected function queryFiles ( $ strAction ) { if ( ! in_array ( $ strAction , [ 'create' , 'insert' , 'drop' ] ) ) throw new Exception ( 'Invalid parameter "' . $ strAction . '" sent to SudoBible::queryFiles()' ) ; $ strPath = 'queries/' . $ this -> dbType . '/' . $ strAction ; foreach ( scandir ( $ strPath ) as $ st... | Run the query files in a given directory . |
9,958 | public function topic ( $ mTopic , $ bRandomOne = false ) { if ( is_string ( $ mTopic ) ) $ mTopic = $ this -> getIdFor ( 'topic' , $ mTopic ) ; $ q = 'SELECT tv.*, verses.`text`, books.`name` AS book_name, books.`abbr` AS book_abbr, books.`ot`, books.`nt`' . ' FROM `sudo_bible_topic_verses` AS tv' . ' LEFT JOIN `sudo_... | Return all verses on a single topic . |
9,959 | public function nextVerse ( $ mBook , $ iChapter , $ iVerse ) { $ oPassage = new SudoBiblePassage ( [ ] , $ this ) ; $ iBookId = is_numeric ( $ mBook ) ? $ mBook : getIdFor ( 'book' , $ mBook ) ; $ aSteps = [ [ $ iBookId , $ iChapter , $ iVerse + 1 ] , [ $ iBookId , $ iChapter + 1 , 1 ] , [ $ iBookId + 1 , 1 , 1 ] , ] ... | Get the verse following the given reference . |
9,960 | protected function getIdFor ( $ strType , $ strNameAbbr ) { if ( ! in_array ( $ strType , [ 'book' , 'translation' , 'topic' ] ) ) throw new Exception ( 'Invalid entity type "' . $ strType . '"' ) ; $ strTableName = 'sudo_bible_' . $ strType . 's' ; $ q = 'SELECT `id` FROM `' . $ strTableName . '` WHERE `name` LIKE ?' ... | Get an ID given the name . |
9,961 | protected function runPreparedQuery ( $ strSql , array $ aParams = [ ] ) { $ aRefParams = [ ] ; foreach ( $ aParams as $ k => $ v ) $ aRefParams [ $ k ] = & $ aParams [ $ k ] ; $ strDataTypes = '' ; foreach ( $ aRefParams as $ mValue ) $ strDataTypes .= is_int ( $ mValue ) ? 'i' : 's' ; array_unshift ( $ aRefParams , $... | Run a mysqli prepared query given the query string and params . |
9,962 | protected static function tryDelete ( $ path ) { $ success = true ; try { if ( ! @ unlink ( $ path ) ) { $ success = false ; } } catch ( ErrorException $ e ) { $ success = false ; } return $ success ; } | Try to delete a file |
9,963 | public function makeLogEvent ( $ name , $ eventListener , $ status ) { if ( $ this -> options [ 'log_events' ] && ( $ this -> options [ 'log_all_events' ] || in_array ( $ name , $ this -> logEvents , true ) ) ) { $ this -> loggerInstance -> makeLog ( [ 'event_name' => $ name , 'listener' => $ this -> getListenerData ( ... | check that event data can be logged and create log message |
9,964 | protected function findModel ( $ id ) { if ( ( $ model = ProductTypeMeta :: findOne ( $ id ) ) !== null ) { return $ model ; } else { throw new NotFoundHttpException ( t ( 'app' , 'The requested page does not exist.' ) ) ; } } | Finds the ProductTypeMeta model based on its primary key value . If the model is not found a 404 HTTP exception will be thrown . |
9,965 | public static function enable ( ) { if ( ! is_array ( $ functions = spl_autoload_functions ( ) ) ) { return ; } foreach ( $ functions as $ function ) { spl_autoload_unregister ( $ function ) ; } foreach ( $ functions as $ function ) { if ( is_array ( $ function ) && $ function [ 0 ] instanceof UniversalClassLoader ) { ... | Replaces all regular UniversalClassLoader instances by a DebugUniversalClassLoader ones . |
9,966 | static function createFromData ( $ data ) { $ instance = new static ( ) ; $ instance -> day = $ data [ 0 ] ; $ instance -> hour = $ data [ 1 ] ; $ instance -> numberCommits = $ data [ 2 ] ; return $ instance ; } | Number of commits |
9,967 | public function registerResource ( Resources \ Resource $ resource ) { $ this -> resources [ strtolower ( $ resource -> getName ( ) ) ] = $ resource ; } | Registers a resource . |
9,968 | public function authorize ( $ args ) { $ numArgs = func_num_args ( ) ; if ( $ numArgs === 0 ) { throw new \ InvalidArgumentException ( 'Wrapper->authorize expects atleast 1 argument!' ) ; return ; } if ( $ numArgs === 1 ) { $ arg1 = func_get_arg ( 0 ) ; if ( $ arg1 instanceof OAuthResponse ) { $ this -> accessToken = $... | Enables the authorized requests . |
9,969 | public function hasScope ( $ name , $ strict = true ) { if ( ! $ strict ) { if ( empty ( $ this -> registeredScopes ) ) { return true ; } } return in_array ( $ name , $ this -> registeredScopes ) ; } | Checks if scope is registered . |
9,970 | public function checkScope ( $ name , $ strict = false ) { if ( ! $ this -> hasScope ( $ name , $ strict ) ) { throw new Exceptions \ OutOfScopeException ( "Scope $name is not registered!" ) ; } } | Checks if scope is registered Throws an exception if scope doesn t exist . |
9,971 | public function resource ( $ name ) { if ( ! isset ( $ this -> resources [ $ name ] ) ) { throw new Exceptions \ ResourceException ( "Resource $name does not exist!" ) ; return ; } return $ this -> resources [ $ name ] ; } | Returns an API resource . |
9,972 | public function request ( $ type , $ target , $ options = [ ] , $ authorized = false ) { $ headers = [ 'Accept' => 'application/vnd.twitchtv.v3+json' , ] ; if ( $ authorized ) { $ headers [ 'Authorization' ] = 'OAuth ' . $ this -> accessToken ; } $ options = array_merge_recursive ( [ 'headers' => $ headers ] , $ option... | Makes a GuzzleHttp request . |
9,973 | public function addJob ( Job \ WrappedJob $ job , $ queue ) { $ qb = $ this -> conn -> createQueryBuilder ( ) ; $ qb -> insert ( $ this -> table_name ) ; $ qb -> values ( [ 'status' => ':status' , 'job' => ':job' , 'name' => ':name' , 'queue' => ':queue' , 'created_at' => ':created_at' , 'available_at' => ':available_a... | add a new wrapped job |
9,974 | public function getAvailableJobs ( $ queue , $ max = 10 ) { $ qb = $ this -> conn -> createQueryBuilder ( ) ; $ qb -> select ( '*' ) ; $ qb -> from ( $ this -> table_name ) ; $ qb -> where ( 'status = :status AND queue = :queue AND available_at <= :now' ) ; $ qb -> orderBy ( 'status' ) ; $ qb -> setParameters ( [ 'stat... | get available jobs |
9,975 | public function initialize ( Controller $ controller ) { parent :: initialize ( $ controller ) ; $ loginUrl = array ( 'plugin' => 'users' , 'controller' => 'users' , 'action' => 'login' , 'admin' => false , ) ; if ( ! empty ( $ controller -> request -> params [ 'tenant' ] ) ) { $ loginUrl [ 'action' ] = 'tenant_login' ... | Initializes AuthComponent for use in the controller . |
9,976 | public function isAuthorized ( $ user = null , CakeRequest $ request = null ) { if ( empty ( $ user ) && ! $ this -> user ( ) ) { return false ; } if ( empty ( $ user ) ) { $ user = $ this -> user ( ) ; } if ( empty ( $ request ) ) { $ request = $ this -> request ; } if ( empty ( $ this -> _authorizeObjects ) ) { $ thi... | Al contrario que el isAuthorized que viene en CakePhp este se fija si algun Adapter retorna false y entonces retorna false . |
9,977 | public function getStreams ( $ params = [ ] ) { $ defaults = [ 'game' => null , 'channel' => null , 'limit' => 25 , 'offset' => 0 , 'client_id' => null , 'stream_type' => 'all' , ] ; $ types = [ 'stream_type' => [ 'all' , 'playlist' , 'live' ] , ] ; return $ this -> wrapper -> request ( 'GET' , 'streams' , [ 'query' =>... | Returns a list of stream objects that are queried by a number of parameters sorted by number of viewers descending . |
9,978 | public function entity ( $ entityType , $ id , $ timestamp ) { $ params = array ( 'type_name' => $ entityType , 'id' => $ id , 'timestamp' => $ timestamp , ) ; return $ this -> post ( 'versions/entity' , $ params ) ; } | Retrieve a past value of single entity by primary key and timestamp . |
9,979 | private static function get_sameWith_value ( $ dio , $ rules ) { $ sub_name = $ rules [ 'sameWith' ] ; if ( $ rules instanceof Rules ) { $ sub_filter = clone $ rules ; } else { $ sub_filter = $ rules ; } $ sub_filter [ 'sameWith' ] = false ; $ sub_filter [ 'required' ] = false ; $ value = $ dio -> find ( $ sub_name , $... | find the same with value . |
9,980 | public function get ( $ key ) { $ ret = $ this -> traverseTree ( $ key ) ; if ( ! is_scalar ( $ ret ) ) { throw new UnexpectedValueException ( "The {$key} configuration value is not scalar" ) ; } return $ ret ; } | Get a value for a configuration key |
9,981 | protected function traverseTree ( $ path ) { $ currentNode = $ this -> tree ; $ pathElements = explode ( static :: KEY_NODE_DELIMITER , $ path ) ; foreach ( $ pathElements as $ node ) { if ( ! isset ( $ currentNode [ $ node ] ) ) { throw new MissingKeyException ( "{$path} configuration value is not found" ) ; } $ curre... | Traverse a tree until the end of path is reached |
9,982 | public function match ( string $ subject , int $ flags = 0 , int $ offset = 0 ) : array { preg_match ( $ this -> pattern -> getPattern ( ) . $ this -> modifier , $ subject , $ matches , $ flags , $ offset ) ; if ( ( $ errno = preg_last_error ( ) ) !== PREG_NO_ERROR ) { $ message = array_flip ( get_defined_constants ( t... | Retrieve match from subject with Pattern |
9,983 | public function setHelperSet ( HelperSet $ helperSet ) { parent :: setHelperSet ( $ helperSet ) ; $ this -> getHelper ( 'phpdocumentor_logger' ) -> addOptions ( $ this ) ; } | Registers the current command . |
9,984 | public function toArray ( ) { $ response = array ( ) ; foreach ( $ this -> items as $ key => $ item ) { $ response [ ] = $ item -> toArray ( ) ; } return $ response ; } | Return collection as array |
9,985 | public function lOr ( ) { $ args = func_get_args ( ) ; if ( count ( $ args ) < 1 ) { throw new ezcQueryVariableParameterException ( 'lOr' , count ( $ args ) , 1 ) ; } $ elements = ezcQuerySelect :: arrayFlatten ( $ args ) ; if ( count ( $ elements ) == 1 ) { return $ elements [ 0 ] ; } else { return '( ' . join ( ' OR ... | Returns the SQL to bind logical expressions together using a logical or . |
9,986 | public function eq ( $ value1 , $ value2 ) { $ value1 = $ this -> getIdentifier ( $ value1 ) ; $ value2 = $ this -> getIdentifier ( $ value2 ) ; return "{$value1} = {$value2}" ; } | Returns the SQL to check if two values are equal . |
9,987 | public function neq ( $ value1 , $ value2 ) { $ value1 = $ this -> getIdentifier ( $ value1 ) ; $ value2 = $ this -> getIdentifier ( $ value2 ) ; return "{$value1} <> {$value2}" ; } | Returns the SQL to check if two values are unequal . |
9,988 | public function gt ( $ value1 , $ value2 ) { $ value1 = $ this -> getIdentifier ( $ value1 ) ; $ value2 = $ this -> getIdentifier ( $ value2 ) ; return "{$value1} > {$value2}" ; } | Returns the SQL to check if one value is greater than another value . |
9,989 | public function gte ( $ value1 , $ value2 ) { $ value1 = $ this -> getIdentifier ( $ value1 ) ; $ value2 = $ this -> getIdentifier ( $ value2 ) ; return "{$value1} >= {$value2}" ; } | Returns the SQL to check if one value is greater than or equal to another value . |
9,990 | public function lt ( $ value1 , $ value2 ) { $ value1 = $ this -> getIdentifier ( $ value1 ) ; $ value2 = $ this -> getIdentifier ( $ value2 ) ; return "{$value1} < {$value2}" ; } | Returns the SQL to check if one value is less than another value . |
9,991 | public function lte ( $ value1 , $ value2 ) { $ value1 = $ this -> getIdentifier ( $ value1 ) ; $ value2 = $ this -> getIdentifier ( $ value2 ) ; return "{$value1} <= {$value2}" ; } | Returns the SQL to check if one value is less than or equal to another value . |
9,992 | public function between ( $ expression , $ value1 , $ value2 ) { $ expression = $ this -> getIdentifier ( $ expression ) ; $ value1 = $ this -> getIdentifier ( $ value1 ) ; $ value2 = $ this -> getIdentifier ( $ value2 ) ; return "{$expression} BETWEEN {$value1} AND {$value2}" ; } | Returns SQL that checks if an expression evaluates to a value between two values . |
9,993 | public function bitAnd ( $ value1 , $ value2 ) { $ value1 = $ this -> getIdentifier ( $ value1 ) ; $ value2 = $ this -> getIdentifier ( $ value2 ) ; return "( {$value1} & {$value2} )" ; } | Returns the SQL that performs the bitwise AND on two values . |
9,994 | public function bitOr ( $ value1 , $ value2 ) { $ value1 = $ this -> getIdentifier ( $ value1 ) ; $ value2 = $ this -> getIdentifier ( $ value2 ) ; return "( {$value1} | {$value2} )" ; } | Returns the SQL that performs the bitwise OR on two values . |
9,995 | protected function prepareArray ( array $ conditions ) { switch ( count ( $ conditions ) ) { case 1 : $ result = $ conditions [ 0 ] ; break ; case 2 : if ( is_array ( $ conditions [ 1 ] ) ) { $ result = $ conditions [ 0 ] . ' IN (' . implode ( ',' , $ conditions [ 1 ] ) . ')' ; } elseif ( is_null ( $ conditions [ 1 ] )... | Array to string |
9,996 | public function checkEmailVerification ( MvcEvent $ event ) { $ services = $ event -> getApplication ( ) -> getServiceManager ( ) ; $ appConfig = $ services -> get ( 'config' ) ; $ config = $ this -> defaultConfig ; if ( array_key_exists ( self :: CONFIG_KEY , $ appConfig ) ) { $ config = $ appConfig [ self :: CONFIG_K... | Check if the email address is verified and if not redirects to a specified route . |
9,997 | public static function fromArrayAndSettings ( $ cfg , $ settings ) { $ directorySpecification = new self ( $ cfg , $ settings -> getDirectory ( ) ) ; $ directorySpecification -> set ( "source" , $ settings -> getPath ( $ directorySpecification -> getSource ( ) ) ) ; $ directorySpecification -> set ( "baseTarget" , $ se... | Creates a directory specification from a plain settings array . The settings context is taken into consideration to generate paths relative to the settings . |
9,998 | public function getFileSpecifications ( ) { $ fileSpecifications = array ( ) ; foreach ( new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ this -> getSource ( ) ) ) as $ entry ) if ( ! fphp \ Helper \ Path :: isDot ( $ entry ) ) { $ fileSource = $ entry -> getPathName ( ) ; if ( is_link ( $ fileSou... | Returns the file specifications this directory specification applies to . The entire source directory tree is considered except for excluded files . |
9,999 | public function getRemoteObject ( $ key , $ interface = null ) { if ( $ interface ) { if ( $ this -> logger !== null && $ this -> logger -> isHandling ( \ Monolog \ Logger :: DEBUG ) ) { $ this -> logger -> addDebug ( 'Create new virtual remote object proxy' , array ( 'interface' => $ interface , 'path' => $ key ) ) ; ... | Get a named remote object proxy . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.