idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
34,300 | private function moveToFirstConcept ( $ nav , & $ contexts , & $ units ) { $ nav -> MoveToDocumentElement ( ) ; $ result = $ nav -> MoveToChild ( XPathNodeType :: Element ) ; while ( $ result ) { switch ( $ nav -> getLocalName ( ) ) { case 'schemaRef' : break ; case 'linkbaseRef' : break ; case 'context' : $ id = $ nav... | Move the navigator to the first concept in the document processng all elements along the way |
34,301 | private function addContexts ( & $ document , $ xbrldiPrefix ) { foreach ( $ this -> contexts as $ contextRef => $ context ) { $ document [ ] = " <context id=\"$contextRef\">" ; if ( isset ( $ context [ 'entity' ] ) ) { $ document [ ] = " <entity>" ; if ( isset ( $ context [ 'entity' ] [ 'identifier' ] ) ) { $ docu... | An array to which context information should be added |
34,302 | private function addComponent ( $ componentType , $ component , & $ document , $ prefix , $ xbrldiPrefix ) { $ entry [ ] = "<$componentType>" ; foreach ( $ component as $ memberType => $ members ) { switch ( $ memberType ) { case 'member' : foreach ( $ members as $ member ) { $ attributesList = array ( ) ; $ attributes... | Add the details for an OCC |
34,303 | private function addUnits ( & $ document ) { foreach ( $ this -> units as $ unitRef => $ unit ) { $ entry = array ( ) ; $ entry [ ] = " <unit id=\"$unitRef\">" ; if ( isset ( $ unit [ 'divide' ] ) ) { $ entry [ ] = " <divide>" ; if ( isset ( $ unit [ 'divide' ] [ 'numerator' ] ) && count ( $ unit [ 'divide' ] [ 'nu... | An array to which unit information should be added |
34,304 | public function getQName ( ) { if ( ! $ this -> qname ) { if ( ! property_exists ( $ this , 'name' ) ) return null ; $ this -> qname = $ qname = new QName ( $ this -> name [ 'originalPrefix' ] , $ this -> name [ 'namespace' ] , $ this -> name [ 'name' ] ) ; } return $ this -> qname ; } | Return the QName of the name property if any |
34,305 | public static function createFromDateInterval ( DateInterval $ interval ) { $ obj = new self ( 'PT0S' ) ; foreach ( $ interval as $ property => $ value ) { $ obj -> $ property = $ value ; } return $ obj ; } | Create an instance of this class from an existing DateInterval instance |
34,306 | public function validate ( $ variableSet , $ nsMgr ) { if ( ! $ this -> name ) { \ XBRL_Log :: getInstance ( ) -> formula_validation ( 'Custom function' , 'Custom function name is not defined' , array ( 'error' => 'xbrlve:noNameForCustomFunction' ) ) ; return false ; } $ qname = $ this -> getQName ( ) ; if ( $ qname ->... | Validate the signature values |
34,307 | private function processElement ( $ elements ) { foreach ( $ elements as $ name => $ value ) { if ( $ value -> count ( ) ) continue ; if ( ! property_exists ( $ this , $ name ) ) continue ; $ this -> $ name = ( string ) $ value ; } } | Grab the values from the XML |
34,308 | private function processXBRLFiles ( $ elements ) { $ xbrlFiles = array ( ) ; foreach ( $ elements as $ name => $ element ) { $ xbrlFile = array ( ) ; foreach ( $ element -> attributes ( XBRL_SEC_XML_Package :: edgarNamespace ) as $ attributeName => $ value ) { $ xbrlFile [ $ attributeName ] = ( string ) $ value ; } $ x... | Extract the file names from the manifest |
34,309 | public function getValue ( $ variableSet , $ evaluationResult , $ log ) { if ( ! isset ( $ variableSet -> context ) ) return array ( ) ; $ sourceContext = $ variableSet -> getComponentForPath ( $ this -> source , $ variableSet -> explicitDimensionsComponentPath , 'explicitMember' , $ evaluationResult , $ this -> aspect... | Get the explicity dimension context information for this rule |
34,310 | private function roundValue ( $ value , $ precision ) { if ( $ precision == INF ) return $ value ; return round ( $ value , \ XBRL_Instance :: inferDecimals ( $ value , $ precision ) ) ; } | Rounds a fact value takng into account the fact precision |
34,311 | private function evaluateAcceptanceRadius ( $ variableSet , $ derivedValue , $ fact , $ factVars = array ( ) ) { if ( is_null ( $ this -> radiusValue ) ) { if ( ! is_null ( $ this -> absoluteAcceptanceRadius ) || ! is_null ( $ this -> proportionalAcceptanceRadius ) ) { $ expression = ! is_null ( $ this -> absoluteAccep... | Check the value is wthin the acceptance radius |
34,312 | public function getUserWithFields ( array $ fields , IncomingMessage $ matchingMessage ) { $ messagingDetails = $ this -> event -> get ( 'messaging' ) [ 0 ] ; $ fields = implode ( ',' , $ fields ) ; if ( isset ( $ messagingDetails [ 'sender' ] [ 'community' ] ) ) { $ fields = 'first_name,last_name,email,title,departmen... | Retrieve specific User field information . |
34,313 | public function handover ( IncomingMessage $ message , $ bot ) { return $ this -> http -> post ( $ this -> facebookProfileEndpoint . 'me/pass_thread_control?access_token=' . $ this -> config -> get ( 'token' ) , [ ] , [ 'recipient' => [ 'id' => $ message -> getSender ( ) , ] , 'target_app_id' => self :: HANDOVER_INBOX_... | Pass a conversation to the page inbox . |
34,314 | public function getFiles ( array $ message ) { return Collection :: make ( $ message [ 'message' ] [ 'attachments' ] ) -> where ( 'type' , 'file' ) -> pluck ( 'payload' ) -> map ( function ( $ item ) { return new File ( $ item [ 'url' ] , $ item ) ; } ) -> toArray ( ) ; } | Retrieve file urls from an incoming message . |
34,315 | public function getLocation ( array $ messages ) { $ data = Collection :: make ( $ messages [ 'message' ] [ 'attachments' ] ) -> where ( 'type' , 'location' ) -> pluck ( 'payload' ) -> first ( ) ; return new Location ( $ data [ 'coordinates' ] [ 'lat' ] , $ data [ 'coordinates' ] [ 'long' ] , $ data ) ; } | Retrieve location from an incoming message . |
34,316 | public function getVideoUrls ( array $ message ) { return Collection :: make ( $ message [ 'message' ] [ 'attachments' ] ) -> where ( 'type' , 'video' ) -> pluck ( 'payload' ) -> map ( function ( $ item ) { return new Video ( $ item [ 'url' ] , $ item ) ; } ) -> toArray ( ) ; } | Retrieve video urls from an incoming message . |
34,317 | public function getAudioUrls ( array $ message ) { return Collection :: make ( $ message [ 'message' ] [ 'attachments' ] ) -> where ( 'type' , 'audio' ) -> pluck ( 'payload' ) -> map ( function ( $ item ) { return new Audio ( $ item [ 'url' ] , $ item ) ; } ) -> toArray ( ) ; } | Retrieve audio file urls from an incoming message . |
34,318 | public static function number ( $ val , $ min = null , $ max = null , $ flags = 0 ) : bool { if ( ! \ is_numeric ( $ val ) ) { return false ; } if ( $ val <= 0 ) { return false ; } return self :: integer ( $ val , $ min , $ max , $ flags ) ; } | check var is a integer and greater than 0 |
34,319 | public static function string ( $ val , $ minLen = 0 , $ maxLen = null ) : bool { if ( ! \ is_string ( $ val ) ) { return false ; } if ( $ minLen === 0 && $ maxLen === null ) { return true ; } return self :: integer ( Helper :: strlen ( $ val ) , $ minLen , $ maxLen ) ; } | check val is a string |
34,320 | public static function eq ( $ val , $ expected , $ strict = true ) : bool { return $ strict ? $ val === $ expected : $ val == $ expected ; } | Must be equal to the given value |
34,321 | public static function neq ( $ val , $ expected , $ strict = true ) : bool { return $ strict ? $ val !== $ expected : $ val != $ expected ; } | Cannot be equal to a given value |
34,322 | public static function isDate ( $ date ) : bool { if ( ! \ preg_match ( '/^([\d]{4})-((?:0?[\d])|(?:1[0-2]))-((?:0?[\d])|(?:[1-2][\d])|(?:3[01]))( [\d]{2}:[\d]{2}:[\d]{2})?$/' , $ date , $ matches ) ) { return false ; } return \ checkdate ( ( int ) $ matches [ 2 ] , ( int ) $ matches [ 3 ] , ( int ) $ matches [ 1 ] ) ;... | Check for date validity |
34,323 | public static function isFloat ( $ float ) : bool { if ( ! \ is_scalar ( $ float ) ) { return false ; } return ( string ) ( ( float ) $ float ) === ( string ) $ float ; } | Check for a float number validity |
34,324 | protected function applyRule ( $ fields , array $ rule , array $ onlyChecked ) { $ fields = \ is_string ( $ fields ) ? Filters :: explode ( $ fields ) : ( array ) $ fields ; $ validator = \ array_shift ( $ rule ) ; $ isEmpty = [ Validators :: class , 'isEmpty' ] ; if ( ! empty ( $ rule [ 'isEmpty' ] ) && ( \ is_string ... | apply validate rule for given fields |
34,325 | protected function collectSafeValue ( string $ field , $ value ) { if ( $ pos = \ strpos ( $ field , '.' ) ) { $ field = ( string ) \ substr ( $ field , 0 , $ pos ) ; $ value = $ this -> getRaw ( $ field , [ ] ) ; } $ this -> _safeData [ $ field ] = $ value ; } | collect Safe Value |
34,326 | public function setRaw ( string $ key , $ value ) : self { $ this -> data [ $ key ] = $ value ; return $ this ; } | Set data item by key |
34,327 | public static function trim ( $ val ) { return \ is_array ( $ val ) ? \ array_map ( function ( $ val ) { return \ is_string ( $ val ) ? \ trim ( $ val ) : $ val ; } , $ val ) : \ trim ( ( string ) $ val ) ; } | simple trim space |
34,328 | public static function lowercase ( $ val ) : string { if ( ! $ val || ! \ is_string ( $ val ) ) { return \ is_int ( $ val ) ? $ val : '' ; } if ( \ function_exists ( 'mb_strtolower' ) ) { return \ mb_strtolower ( $ val , 'utf-8' ) ; } return \ strtolower ( $ val ) ; } | string to lowercase |
34,329 | public static function uppercase ( $ str ) : string { if ( ! $ str || ! \ is_string ( $ str ) ) { return \ is_int ( $ str ) ? $ str : '' ; } if ( \ function_exists ( 'mb_strtoupper' ) ) { return \ mb_strtoupper ( $ str , 'utf-8' ) ; } return \ strtoupper ( $ str ) ; } | string to uppercase |
34,330 | public static function snakeCase ( $ val , string $ sep = '_' ) : string { if ( ! $ val || ! \ is_string ( $ val ) ) { return '' ; } $ val = \ preg_replace ( '/([A-Z][a-z])/' , $ sep . '$1' , $ val ) ; return self :: lowercase ( \ trim ( $ val , $ sep ) ) ; } | Transform a CamelCase string to underscore_case string CMSCategories = > cms_categories RangePrice = > range_price |
34,331 | public static function compareSize ( $ val , string $ operator , $ expected ) : bool { if ( \ gettype ( $ val ) !== \ gettype ( $ expected ) ) { return false ; } if ( ( $ len = self :: length ( $ val ) ) < 0 ) { return false ; } $ wantLen = self :: length ( $ expected ) ; switch ( $ operator ) { case '>' : $ ok = $ len... | compare of size - int Compare size - string Compare length - array Compare length |
34,332 | public function inError ( string $ field ) : bool { foreach ( $ this -> _errors as $ item ) { if ( $ field === $ item [ 'name' ] ) { return true ; } } return false ; } | check field whether in the errors |
34,333 | public function firstError ( bool $ onlyMsg = true ) { if ( ! $ errors = $ this -> _errors ) { return $ onlyMsg ? '' : [ ] ; } $ first = \ array_shift ( $ errors ) ; return $ onlyMsg ? $ first [ 'msg' ] : $ first ; } | Get the first error message |
34,334 | public function lastError ( bool $ onlyMsg = true ) { if ( ! $ errors = $ this -> _errors ) { return $ onlyMsg ? '' : [ ] ; } $ last = \ array_pop ( $ errors ) ; return $ onlyMsg ? $ last [ 'msg' ] : $ last ; } | Get the last error message |
34,335 | public function addTranslates ( array $ fieldTrans ) : self { foreach ( $ fieldTrans as $ field => $ tran ) { $ this -> _translates [ $ field ] = $ tran ; } return $ this ; } | add the attrs translation data |
34,336 | public function getTranslate ( string $ field ) : string { $ trans = $ this -> getTranslates ( ) ; if ( isset ( $ trans [ $ field ] ) ) { return $ trans [ $ field ] ; } if ( $ this -> _prettifyName ) { return Helper :: prettifyFieldName ( $ field ) ; } return $ field ; } | get field translate string . |
34,337 | public function cropFaceToJpeg ( $ outFileName = null ) { if ( empty ( $ this -> face ) ) { throw new NoFaceException ( 'No face detected' ) ; } $ canvas = imagecreatetruecolor ( $ this -> face [ 'w' ] , $ this -> face [ 'w' ] ) ; imagecopy ( $ canvas , $ this -> canvas , 0 , 0 , $ this -> face [ 'x' ] , $ this -> face... | Crops the face from the photo . Should be called after faceDetect function call If file is provided the face will be stored in file other way it will be output to standard output . |
34,338 | public static function match ( $ value , $ comparable ) { if ( is_array ( $ comparable ) || is_array ( $ value ) || is_object ( $ comparable ) || is_object ( $ value ) ) { return false ; } $ comparable = trim ( $ comparable ) ; if ( preg_match ( "/^$comparable$/" , $ value ) ) { return true ; } return false ; } | Match with pattern |
34,339 | public function import ( $ file = null ) { if ( ! is_null ( $ file ) ) { if ( is_string ( $ file ) && file_exists ( $ file ) ) { $ this -> _map = $ this -> getDataFromFile ( $ file ) ; $ this -> _baseContents = $ this -> _map ; return true ; } } throw new FileNotFoundException ( ) ; } | import data from file |
34,340 | protected function prepare ( ) { if ( $ this -> _isProcessed ) { return $ this ; } if ( count ( $ this -> _conditions ) > 0 ) { $ calculatedData = $ this -> processConditions ( ) ; $ this -> _map = $ this -> objectToArray ( $ calculatedData ) ; $ this -> _conditions = [ ] ; $ this -> _node = '' ; $ this -> _isProcessed... | Prepare data from desire conditions |
34,341 | protected function objectToArray ( $ obj ) { if ( ! is_array ( $ obj ) && ! is_object ( $ obj ) ) { return $ obj ; } if ( is_array ( $ obj ) ) { return $ obj ; } if ( is_object ( $ obj ) ) { $ obj = get_object_vars ( $ obj ) ; } return array_map ( [ $ this , 'objectToArray' ] , $ obj ) ; } | Parse object to array |
34,342 | protected function isMultiArray ( $ arr ) { if ( ! is_array ( $ arr ) ) { return false ; } rsort ( $ arr ) ; return isset ( $ arr [ 0 ] ) && is_array ( $ arr [ 0 ] ) ; } | Check given value is multidimensional array |
34,343 | public function isJson ( $ value , $ isReturnMap = false ) { if ( is_array ( $ value ) || is_object ( $ value ) ) { return false ; } $ data = json_decode ( $ value , true ) ; if ( json_last_error ( ) !== JSON_ERROR_NONE ) { return false ; } return $ isReturnMap ? $ data : true ; } | Check given value is valid JSON |
34,344 | protected function prepareResult ( $ data , $ isObject ) { $ output = [ ] ; if ( is_null ( $ data ) || is_scalar ( $ data ) ) { return $ data ; } if ( $ this -> isMultiArray ( $ data ) ) { foreach ( $ data as $ key => $ val ) { $ val = $ this -> takeColumn ( $ val ) ; $ output [ $ key ] = $ isObject ? ( object ) $ val ... | Prepare data for result |
34,345 | protected function getDataFromFile ( $ file , $ type = 'application/json' ) { if ( file_exists ( $ file ) ) { $ opts = [ 'http' => [ 'header' => 'Content-Type: ' . $ type . '; charset=utf-8' , ] , ] ; $ context = stream_context_create ( $ opts ) ; $ data = file_get_contents ( $ file , 0 , $ context ) ; $ json = $ this ... | Read JSON data from file |
34,346 | protected function getFromNested ( $ map , $ node ) { if ( empty ( $ node ) || $ node == '.' ) { return $ map ; } if ( $ node ) { $ terminate = false ; $ path = explode ( '.' , $ node ) ; foreach ( $ path as $ val ) { if ( ! array_key_exists ( $ val , $ map ) ) { $ terminate = true ; break ; } $ map = & $ map [ $ val ]... | Get data from nested array |
34,347 | protected function processConditions ( ) { $ data = $ this -> getData ( ) ; $ conditions = $ this -> _conditions ; $ result = array_filter ( $ data , function ( $ val ) use ( $ conditions ) { $ res = false ; foreach ( $ conditions as $ cond ) { $ tmp = true ; foreach ( $ cond as $ rule ) { $ function = self :: $ _rules... | process AND and OR conditions |
34,348 | public function where ( $ key , $ condition = null , $ value = null ) { if ( ! is_null ( $ condition ) && is_null ( $ value ) ) { $ value = $ condition ; $ condition = '=' ; } if ( count ( $ this -> _conditions ) < 1 ) { array_push ( $ this -> _conditions , [ ] ) ; } return $ this -> makeWhere ( $ key , $ condition , $... | make WHERE clause |
34,349 | public function orWhere ( $ key = null , $ condition = null , $ value = null ) { if ( ! is_null ( $ condition ) && is_null ( $ value ) ) { $ value = $ condition ; $ condition = '=' ; } array_push ( $ this -> _conditions , [ ] ) ; return $ this -> makeWhere ( $ key , $ condition , $ value ) ; } | make WHERE clause with OR |
34,350 | protected function makeWhere ( $ key , $ condition = null , $ value = null ) { $ current = end ( $ this -> _conditions ) ; $ index = key ( $ this -> _conditions ) ; if ( is_callable ( $ key ) ) { $ key ( $ this ) ; return $ this ; } array_push ( $ current , [ 'key' => $ key , 'condition' => $ condition , 'value' => $ v... | generator for AND and OR where |
34,351 | public function whereBool ( $ key = null , $ value ) { if ( is_bool ( $ value ) ) { $ this -> where ( $ key , '==' , $ value ) ; } return $ this ; } | make WHERE Boolean clause |
34,352 | public static function macro ( $ name , callable $ fn ) { if ( ! in_array ( $ name , self :: $ _rulesMap ) ) { self :: $ _rulesMap [ $ name ] = $ fn ; return true ; } return false ; } | make macro for custom where clause |
34,353 | public function from ( $ node = null ) { $ this -> _isProcessed = false ; if ( is_null ( $ node ) || $ node == '' ) { throw new NullValueException ( "Null node exception" ) ; } $ this -> _node = $ node ; return $ this ; } | Set node path where JsonQ start to prepare |
34,354 | public function get ( $ object = false ) { $ this -> prepare ( ) ; return $ this -> prepareResult ( $ this -> _map , $ object ) ; } | getting prepared data |
34,355 | public function groupBy ( $ column ) { $ this -> prepare ( ) ; $ data = [ ] ; foreach ( $ this -> _map as $ map ) { $ value = $ this -> getFromNested ( $ map , $ column ) ; if ( $ value ) { $ data [ $ value ] [ ] = $ map ; } } $ this -> _map = $ data ; return $ this ; } | getting group data from specific column |
34,356 | public function sum ( $ column = null ) { $ this -> prepare ( ) ; $ sum = 0 ; if ( is_null ( $ column ) ) { $ sum = array_sum ( $ this -> _map ) ; } else { foreach ( $ this -> _map as $ key => $ val ) { $ value = $ this -> getFromNested ( $ val , $ column ) ; if ( is_scalar ( $ value ) ) { $ sum += $ value ; } } } retu... | sum prepared data |
34,357 | public function max ( $ column = null ) { $ this -> prepare ( ) ; if ( is_null ( $ column ) ) { $ max = max ( $ this -> _map ) ; } else { $ max = max ( array_column ( $ this -> _map , $ column ) ) ; } return $ max ; } | getting max value from prepared data |
34,358 | public function min ( $ column = null ) { $ this -> prepare ( ) ; if ( is_null ( $ column ) ) { $ min = min ( $ this -> _map ) ; } else { $ min = min ( array_column ( $ this -> _map , $ column ) ) ; } return $ min ; } | getting min value from prepared data |
34,359 | public function avg ( $ column = null ) { $ this -> prepare ( ) ; $ count = $ this -> count ( ) ; $ total = $ this -> sum ( $ column ) ; return ( $ total / $ count ) ; } | getting average value from prepared data |
34,360 | public function first ( $ object = false ) { $ this -> prepare ( ) ; $ data = $ this -> _map ; if ( count ( $ data ) > 0 ) { return $ this -> prepareResult ( reset ( $ data ) , $ object ) ; } return null ; } | getting first element of prepared data |
34,361 | public function last ( $ object = false ) { $ this -> prepare ( ) ; $ data = $ this -> _map ; if ( count ( $ data ) > 0 ) { return $ this -> prepareResult ( end ( $ data ) , $ object ) ; } return null ; } | getting last element of prepared data |
34,362 | public function nth ( $ index , $ object = false ) { $ this -> prepare ( ) ; $ data = $ this -> _map ; $ total_elm = count ( $ data ) ; $ idx = abs ( $ index ) ; if ( ! is_integer ( $ index ) || $ total_elm < $ idx || $ index == 0 || ! is_array ( $ this -> _map ) ) { return null ; } if ( $ index > 0 ) { $ result = $ da... | getting nth number of element of prepared data |
34,363 | public function sortBy ( $ column , $ order = 'asc' ) { $ this -> prepare ( ) ; if ( ! is_array ( $ this -> _map ) ) { return $ this ; } usort ( $ this -> _map , function ( $ a , $ b ) use ( $ column , $ order ) { $ val1 = $ this -> getFromNested ( $ a , $ column ) ; $ val2 = $ this -> getFromNested ( $ b , $ column ) ... | sorting from prepared data |
34,364 | public function sortByCallable ( callable $ sortFunc ) { $ this -> prepare ( ) ; if ( ! is_array ( $ this -> _map ) ) { return $ this ; } usort ( $ this -> _map , $ sortFunc ) ; return $ this ; } | Sort prepared data using a custom sort function . |
34,365 | public function sort ( $ order = 'asc' ) { if ( $ order == 'desc' ) { rsort ( $ this -> _map ) ; } else { sort ( $ this -> _map ) ; } return $ this ; } | Sort an array value |
34,366 | public function find ( $ path , $ object = false ) { return $ this -> from ( $ path ) -> prepare ( ) -> get ( $ object ) ; } | getting data from desire path |
34,367 | public function each ( callable $ fn ) { $ this -> prepare ( ) ; foreach ( $ this -> _map as $ key => $ val ) { $ fn ( $ key , $ val ) ; } } | take action of each element of prepared data |
34,368 | public function transform ( callable $ fn ) { $ this -> prepare ( ) ; $ new_data = [ ] ; foreach ( $ this -> _map as $ key => $ val ) { $ new_data [ $ key ] = $ fn ( $ val ) ; } return $ this -> prepareResult ( $ new_data , false ) ; } | transform prepared data by using callable function |
34,369 | public function pipe ( callable $ fn , $ class = null ) { $ this -> prepare ( ) ; if ( is_string ( $ fn ) && ! is_null ( $ class ) ) { $ instance = new $ class ; $ this -> _map = call_user_func_array ( [ $ instance , $ fn ] , [ $ this ] ) ; return $ this ; } $ this -> _map = $ fn ( $ this ) ; return $ this ; } | pipe send output in next pipe |
34,370 | public function filter ( callable $ fn , $ key = false ) { $ this -> prepare ( ) ; $ data = [ ] ; foreach ( $ this -> _map as $ k => $ val ) { if ( $ fn ( $ val ) ) { if ( $ key ) { $ data [ $ k ] = $ val ; } else { $ data [ ] = $ val ; } } } return $ this -> prepareResult ( $ data , false ) ; } | filtered each element of prepared data |
34,371 | public function then ( $ node ) { $ this -> _map = $ this -> prepare ( ) -> first ( false ) ; $ this -> from ( $ node ) ; return $ this ; } | then method set position of working data |
34,372 | public function json ( $ data ) { $ json = $ this -> isJson ( $ data , true ) ; if ( $ json ) { return $ this -> collect ( $ json ) ; } return $ this ; } | import raw JSON data for process |
34,373 | public function collect ( $ data ) { $ this -> _map = $ this -> objectToArray ( $ data ) ; $ this -> _baseContents = & $ this -> _map ; return $ this ; } | import parsed data from raw json |
34,374 | public function implode ( $ key , $ delimiter = ',' ) { $ this -> prepare ( ) ; $ implode = [ ] ; if ( is_string ( $ key ) ) { return $ this -> makeImplode ( $ key , $ delimiter ) ; } if ( is_array ( $ key ) ) { foreach ( $ key as $ k ) { $ imp = $ this -> makeImplode ( $ k , $ delimiter ) ; $ implode [ $ k ] = $ imp ;... | implode resulting data from desire key and delimeter |
34,375 | protected function makeImplode ( $ key , $ delimiter ) { $ data = array_column ( $ this -> _map , $ key ) ; if ( is_array ( $ data ) ) { return implode ( $ delimiter , $ data ) ; } return null ; } | process implode from resulting data |
34,376 | public function chunk ( $ amount , callable $ fn = null ) { $ this -> prepare ( ) ; $ chunk_value = array_chunk ( $ this -> _map , $ amount ) ; $ chunks = [ ] ; if ( ! is_null ( $ fn ) && is_callable ( $ fn ) ) { foreach ( $ chunk_value as $ chunk ) { $ return = $ fn ( $ chunk ) ; if ( ! is_null ( $ return ) ) { $ chun... | getting chunk values from prepared data |
34,377 | protected function registerJsonManager ( ) { $ config = $ this -> app [ 'config' ] ; $ this -> app -> singleton ( 'jsonq.manager' , function ( ) use ( $ config ) { return new JsonQueriable ( $ config -> get ( 'jsonq.json.storage_path' ) ) ; } ) ; $ this -> app -> alias ( 'jsonq.manager' , JsonQueriable :: class ) ; } | register JsonManager . |
34,378 | public function getBaseDn ( ) { if ( empty ( $ this -> baseDn ) ) { $ this -> setBaseDn ( $ this -> findBaseDn ( ) ) ; } return $ this -> baseDn ; } | Get the current base DN . |
34,379 | public function getPersonFilter ( $ key = null ) { if ( $ key == 'category' ) { return $ this -> personFilter [ 'category' ] ; } if ( $ key == 'person' ) { return $ this -> personFilter [ 'person' ] ; } return implode ( '=' , $ this -> personFilter ) ; } | Get the person search filter . An optional parameter may be used to specify the desired part . Without a parameter returns an imploded string of the form category = person . |
34,380 | public function setPort ( $ adPort ) { if ( ! is_numeric ( $ adPort ) ) { if ( $ adPort === null ) { $ adPort = 'null' ; } throw new AdldapException ( "The Port: $adPort is not numeric and cannot be used." ) ; } $ this -> adPort = ( string ) $ adPort ; } | Sets the port number your domain controller communicates over . |
34,381 | public function setUseSSL ( $ useSSL ) { if ( $ useSSL ) { $ this -> ldapConnection -> useSSL ( ) ; $ this -> setPort ( ConnectionInterface :: PORT_SSL ) ; } else { $ this -> setPort ( ConnectionInterface :: PORT ) ; } } | Set whether to use SSL on the current ldap connection . |
34,382 | public function connect ( ) { $ domainController = $ this -> domainControllers [ array_rand ( $ this -> domainControllers ) ] ; $ port = $ this -> getPort ( ) ; $ this -> ldapConnection -> connect ( $ domainController , $ port ) ; $ this -> ldapConnection -> setOption ( LDAP_OPT_PROTOCOL_VERSION , 3 ) ; $ this -> ldapC... | Connects and Binds to the Domain Controller . |
34,383 | public function authenticate ( $ username , $ password , $ preventRebind = false ) { $ auth = false ; try { if ( $ this -> getUseSSO ( ) ) { $ remoteUser = $ this -> getRemoteUserInput ( ) ; $ kerberos = $ this -> getKerberosAuthInput ( ) ; if ( $ remoteUser == $ username ) { $ auth = $ this -> bindUsingKerberos ( $ ke... | Authenticates a user using the specified credentials . |
34,384 | public function getObjectClass ( $ distinguishedName ) { $ this -> utilities ( ) -> validateNotNull ( 'Distinguished Name [dn]' , $ distinguishedName ) ; $ result = $ this -> search ( ) -> select ( 'objectClass' ) -> where ( 'distinguishedName' , '=' , $ distinguishedName ) -> first ( ) ; if ( is_array ( $ result ) && ... | Returns objectClass in an array . |
34,385 | public function getRootDse ( $ attributes = [ '*' , '+' ] ) { return $ this -> search ( ) -> setDn ( null ) -> read ( true ) -> select ( $ attributes ) -> where ( 'objectClass' , '*' ) -> first ( ) ; } | Get the RootDSE properties from a domain controller . |
34,386 | public function ldapSchema ( array $ attributes ) { array_walk ( $ attributes , [ $ this -> utilities ( ) , 'encode8bit' ] ) ; $ adldapSchema = new AdldapSchema ( $ attributes ) ; $ ldapSchema = new LdapSchema ( $ adldapSchema ) ; if ( $ ldapSchema -> countAttributes ( ) === 0 ) { return false ; } return array_filter (... | Returns an LDAP compatible schema array for modifications . |
34,387 | private function bindUsingKerberos ( $ kerberosCredentials ) { putenv ( 'KRB5CCNAME=' . $ kerberosCredentials ) ; $ bound = $ this -> ldapConnection -> bind ( null , null , true ) ; if ( ! $ bound ) { $ message = 'Bind to Active Directory failed. AD said: ' . $ this -> ldapConnection -> getLastError ( ) ; throw new Adl... | Binds to the current connection using kerberos . |
34,388 | private function bindUsingCredentials ( $ username , $ password ) { if ( empty ( $ username ) ) { $ username = null ; } else { $ username .= $ this -> getAccountSuffix ( ) ; } if ( empty ( $ password ) ) { $ password = null ; } $ this -> ldapConnection -> bind ( $ username , $ password ) ; if ( ! $ this -> ldapConnecti... | Binds to the current connection using the inserted credentials . |
34,389 | public function authenticate ( $ username , $ password , $ preventRebind = false ) { return $ this -> adldap -> authenticate ( $ username , $ password , $ preventRebind ) ; } | Validate a user s login credentials . |
34,390 | public function all ( $ fields = [ ] , $ sorted = true , $ sortBy = 'cn' , $ sortByDirection = 'asc' ) { $ personCategory = $ this -> adldap -> getPersonFilter ( 'category' ) ; $ person = $ this -> adldap -> getPersonFilter ( 'person' ) ; $ search = $ this -> adldap -> search ( ) -> select ( $ fields ) -> where ( $ per... | Returns all users from the current connection . |
34,391 | public function find ( $ username , $ fields = [ ] ) { $ this -> adldap -> utilities ( ) -> validateNotNullOrEmpty ( 'Username' , $ username ) ; $ personCategory = $ this -> adldap -> getPersonFilter ( 'category' ) ; $ person = $ this -> adldap -> getPersonFilter ( 'person' ) ; return $ this -> adldap -> search ( ) -> ... | Finds a user with the specified username in the connection connection . |
34,392 | public function passwordExpiry ( $ username ) { $ this -> adldap -> utilities ( ) -> validateBcmodExists ( ) ; $ user = $ this -> info ( $ username , [ 'pwdlastset' , 'useraccountcontrol' ] ) ; if ( is_array ( $ user ) && array_key_exists ( 'pwdlastset' , $ user ) ) { $ pwdLastSet = $ user [ 'pwdlastset' ] ; $ status =... | Determine a user s password expiry date . |
34,393 | public function modify ( $ username , $ attributes , $ isGUID = false ) { $ user = new User ( $ attributes ) ; $ user -> setAttribute ( 'username' , $ username ) ; if ( $ user -> getAttribute ( 'password' ) && ! $ this -> connection -> canChangePasswords ( ) ) { throw new AdldapException ( 'SSL/TLS must be configured o... | Modify a user . |
34,394 | public function enable ( $ username , $ isGUID = false ) { $ this -> adldap -> utilities ( ) -> validateNotNull ( 'Username' , $ username ) ; $ attributes = [ 'enabled' => 1 ] ; return $ this -> modify ( $ username , $ attributes , $ isGUID ) ; } | Enable a user account . |
34,395 | public function password ( $ username , $ password , $ isGUID = false ) { $ this -> adldap -> utilities ( ) -> validateNotNull ( 'Username' , $ username ) ; $ this -> adldap -> utilities ( ) -> validateNotNull ( 'Password' , $ password ) ; $ this -> adldap -> utilities ( ) -> validateLdapIsBound ( ) ; if ( ! $ this -> ... | Set the password of a user - This must be performed over SSL . |
34,396 | public function changePassword ( $ username , $ password , $ oldPassword , $ isGUID = false ) { $ this -> adldap -> utilities ( ) -> validateNotNull ( 'Username' , $ username ) ; $ this -> adldap -> utilities ( ) -> validateNotNull ( 'Password' , $ password ) ; $ this -> adldap -> utilities ( ) -> validateNotNull ( 'Ol... | Change the password of a user - This must be performed over SSL Requires PHP 5 . 4 > = 5 . 4 . 26 PHP 5 . 5 > = 5 . 5 . 10 or PHP 5 . 6 > = 5 . 6 . 0 . |
34,397 | public function encodePassword ( $ password ) { $ password = '"' . $ password . '"' ; $ encoded = '' ; $ length = strlen ( $ password ) ; for ( $ i = 0 ; $ i < $ length ; $ i ++ ) { $ encoded .= "{$password{$i} }\000" ; } return $ encoded ; } | Encode a password for transmission over LDAP . |
34,398 | public function move ( $ username , $ container ) { $ user = new User ( [ 'username' => $ username , 'container' => $ container , ] ) ; $ user -> validateRequired ( [ 'username' , 'container' ] ) ; $ this -> adldap -> utilities ( ) -> validateLdapIsBound ( ) ; $ userInfo = $ this -> info ( $ user -> getAttribute ( 'use... | Move a user account to a different OU . |
34,399 | public function getLastLogon ( $ username ) { $ this -> adldap -> utilities ( ) -> validateNotNull ( 'Username' , $ username ) ; $ userInfo = $ this -> info ( $ username , [ 'lastlogontimestamp' ] ) ; if ( is_array ( $ userInfo ) && array_key_exists ( 'lastlogontimestamp' , $ userInfo ) ) { return AdldapUtils :: conver... | Get the last logon time of any user as a Unix timestamp . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.