idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
240,500
public function removeWorker ( $ id ) { if ( $ id instanceof Worker ) { $ id = $ id -> getId ( ) ; } if ( isset ( $ this -> waitingList [ $ id ] ) ) { unset ( $ this -> waitingList [ $ id ] ) ; } if ( isset ( $ this -> workerList [ $ id ] ) ) { unset ( $ this -> workerList [ $ id ] ) ; } return $ this ; }
Removes the worker from the action .
240,501
public function addWaitingWorker ( $ id ) { if ( $ id instanceof Worker ) { $ id = $ id -> getId ( ) ; } if ( ! isset ( $ this -> workerList [ $ id ] ) ) { throw new \ Exception ( 'Trying to add non existent worker to the queue.' ) ; } $ worker = $ this -> workerList [ $ id ] ; $ this -> ready = true ; if ( ! isset ( $...
Adds the worker to the waiting list if it is not already in there .
240,502
public function fetchWaitingWorker ( ) { $ count = count ( $ this -> waitingList ) ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { $ worker = array_shift ( $ this -> waitingList ) ; if ( $ worker -> isValid ( ) && $ worker -> isReady ( ) ) { return $ worker ; } } $ this -> ready = false ; return null ; }
Gets the first available worker in the waiting list .
240,503
public function cleanup ( ) { foreach ( $ this -> workerList as $ worker ) { if ( ! $ worker -> isValid ( ) ) { $ this -> removeWorker ( $ worker ) ; } } return $ this ; }
Removes all invalid workers .
240,504
protected function confirmAnUserIsCreatedInAcachaLaravelForge ( ) { $ this -> info ( '' ) ; $ this -> info ( 'Please visit and login on http://forge.acacha.org' ) ; $ this -> info ( '' ) ; $ this -> error ( 'Please use Github Social Login for login!!!' ) ; while ( ! $ this -> confirm ( 'Do you have an user created at h...
Confirm an user is created in Acacha Laravel Forge .
240,505
function getLayout ( ) { $ layoutName = ( $ this -> layout ) ? $ this -> layout : $ this -> getDefaultLayoutName ( ) ; if ( strstr ( $ layoutName , '/' ) === false ) { $ DS = ( defined ( 'DS' ) ) ? constant ( 'DS' ) : DIRECTORY_SEPARATOR ; $ pathname = self :: $ PATH_PREFIX . $ DS . $ this -> deriveLayoutPathPrefix ( )...
Get view script layout
240,506
final function deriveLayoutPathPrefix ( ) { $ moduleNamespace = $ this -> deriveModuleNamespace ( ) ; $ path = ( $ moduleNamespace ) ? $ moduleNamespace . '/' : '' ; $ path .= $ this -> deriveWidgetName ( ) ; $ path = str_replace ( '\\' , '/' , $ this -> inflectName ( $ path ) ) ; return $ path ; }
Get layout path prefixed to module layout name
240,507
private function getConnection ( ) { if ( ! isset ( $ this -> connection ) ) { $ config = new Configuration ( ) ; $ this -> connection = DriverManager :: getConnection ( $ this -> connectionParams , $ config ) ; } return $ this -> connection ; }
Returns the connection object .
240,508
public function setTimezone ( $ timezone ) { $ smt = $ this -> getConnection ( ) -> prepare ( 'SET time_zone = ?' ) ; $ smt -> bindValue ( 1 , $ timezone ) ; $ smt -> execute ( ) ; }
Sets a timezone .
240,509
public function encrypt ( $ data ) { if ( ! $ data || ! is_scalar ( $ data ) ) { return null ; } $ nonce = random_bytes ( SODIUM_CRYPTO_SECRETBOX_NONCEBYTES ) ; $ cipher = sodium_crypto_secretbox ( $ data , $ nonce , $ this -> key ) ; return base64_encode ( $ nonce . $ cipher ) ; }
Encrypt a string .
240,510
protected function checkSite ( ) { $ sites = $ this -> fetchSites ( fp_env ( 'ACACHA_FORGE_SERVER' ) ) ; return in_array ( fp_env ( 'ACACHA_FORGE_SITE' ) , collect ( $ sites ) -> pluck ( 'id' ) -> toArray ( ) ) ; }
Check site .
240,511
protected function checkSiteAndAbort ( $ site = null ) { $ site = $ site ? $ site : fp_env ( 'ACACHA_FORGE_SITE' ) ; if ( ! $ this -> checkSite ( $ site ) ) { $ this -> error ( 'Site ' . $ site . ' not valid' ) ; die ( ) ; } }
Check site and abort .
240,512
public function resolveErrorHandler ( $ errorCode ) { return array_key_exists ( $ errorCode , $ this -> errorHandlers ) ? call_user_func_array ( $ this -> errorHandlers [ $ errorCode ] , [ ] ) : '' ; }
Resolve an error handler
240,513
public function onCreateZone ( ZoneEvent $ event ) { $ zone = $ event -> getZone ( ) ; if ( $ zone -> getComponents ( ) -> isEmpty ( ) ) { return ; } $ this -> save ( $ zone ) ; }
Zone creation event handler . Triggers persistence call only if component was defined into it .
240,514
public function setItem ( $ item , $ index = null ) : ContainerInterface { if ( is_null ( $ index ) ) { $ this -> items [ ] = $ item ; } else { $ this -> items [ $ index ] = $ item ; } return $ this ; }
Set an item into children list .
240,515
public function removeItemByIndex ( $ index ) : ContainerInterface { if ( $ this -> hasItem ( $ index ) ) { $ this -> items [ $ index ] = null ; unset ( $ this -> items [ $ index ] ) ; } return $ this ; }
Removes the child from the children list for the given index .
240,516
protected function getItemsCode ( ) : string { $ code = '' ; if ( $ this -> countItems ( ) > 0 ) { foreach ( $ this -> getAllItems ( ) as $ item ) { if ( is_string ( $ item ) ) { $ code .= $ item ; } else { $ code .= ( string ) $ item ; } } } return $ code ; }
Get html code for children .
240,517
function helper ( $ helper_name ) { if ( array_key_exists ( $ helper_name , $ this -> helpers ) ) { return $ this -> helpers [ $ helper_name ] ; } else { $ classname = 'Helper_' . ucwords ( $ helper_name ) ; return new $ classname ( $ this -> modules , $ this -> server , $ this -> request , $ this -> security ) ; } }
Instanciates a helper .
240,518
function view ( $ view_name , array $ var_list = NULL , array $ block_list = NULL ) { if ( $ var_list === NULL ) { $ var_list = array ( ) ; } $ vars = ( object ) $ var_list ; $ blocks = ( object ) $ block_list ; if ( $ hook_data = $ this -> modules -> preView ( $ this -> request , $ view_name , $ vars ) ) { return $ ho...
Loads a view .
240,519
protected function model ( $ model_name ) { if ( stripos ( $ model_name , 'model' ) === false ) { $ model_name = sprintf ( '%s\models\%s' , $ this -> server -> getAppName ( ) , $ model_name ) ; } if ( $ hook_data = $ this -> modules -> preModel ( $ model_name ) ) { return $ hook_data ; } if ( ! class_exists ( $ model_n...
Loads a model .
240,520
protected function dump ( $ var , $ no_html = false ) { $ dump = var_export ( $ var , true ) ; if ( $ no_html ) { return $ dump ; } else { return '<pre>' . htmlentities ( $ dump ) . '</pre>' . PHP_EOL ; ; } }
Tiny wrapper arround var_dump to ease debugging .
240,521
protected final function checkCsrf ( ) { $ valid = false ; $ r = $ this -> request ; if ( $ r -> getSession ( 'assegai_csrf_token' ) && $ r -> post ( 'csrf' ) && $ r -> getSession ( 'assegai_csrf_token' ) == $ r -> post ( 'csrf' ) ) { $ valid = true ; } $ this -> request -> killSession ( 'assegai_csrf_token' ) ; return...
Checks the validity of the CSRF token .
240,522
public function trigger ( $ eventName , $ origin = null , $ context = [ ] , EventInterface $ event = null ) { if ( $ eventsHandler = $ this -> getEventsHandler ( ) ) { $ eventsHandler -> trigger ( $ eventName , $ origin , $ context , $ event ) ; } }
Proxy trigger method
240,523
public function bind ( $ eventName , $ callback , $ mode = EventsHandlerInterface :: BINDING_MODE_LAST ) { if ( $ eventsHandler = $ this -> getEventsHandler ( ) ) { $ eventsHandler -> bind ( $ eventName , $ callback , $ mode ) ; } }
Proxy bind method
240,524
public function processExchangePlatformOrder ( Varien_Event_Observer $ observer ) { $ order = $ observer -> getEvent ( ) -> getOrder ( ) ; $ quote = $ order -> getQuote ( ) ; Mage :: dispatchEvent ( 'ebayenterprise_giftcard_redeem' , array ( 'quote' => $ quote , 'order' => $ order ) ) ; return $ this ; }
Perform all processing necessary for the order to be placed with the Exchange Platform - allocate inventory redeem SVC . If any of the observers need to indicate that an order should not be created the observer method should throw an exception . Observers the sales_order_place_before event .
240,525
public function rollbackExchangePlatformOrder ( Varien_Event_Observer $ observer ) { Mage :: helper ( 'ebayenterprise_magelog' ) -> debug ( __METHOD__ ) ; Mage :: dispatchEvent ( 'eb2c_order_creation_failure' , array ( 'quote' => $ observer -> getEvent ( ) -> getQuote ( ) , 'order' => $ observer -> getEvent ( ) -> getO...
Roll back any Exchange Platform actions made for the order - rollback allocation void SVC redemptions void payment auths . Observes the sales_model_service_quote_submit_failure event .
240,526
public function handleShipGroupChargeType ( Varien_Event_Observer $ observer ) { $ event = $ observer -> getEvent ( ) ; $ shipGroup = $ event -> getShipGroupPayload ( ) ; Mage :: helper ( 'radial_core/shipping_chargetype' ) -> setShippingChargeType ( $ shipGroup ) ; return $ this ; }
respond to the order create s request for a valid ship group charge type
240,527
public function handleSalesQuoteCollectTotalsAfter ( Varien_Event_Observer $ observer ) { $ event = $ observer -> getEvent ( ) ; $ quote = $ event -> getQuote ( ) ; $ addresses = $ quote -> getAddressesCollection ( ) ; foreach ( $ addresses as $ address ) { $ appliedRuleIds = $ address -> getAppliedRuleIds ( ) ; if ( i...
Account for shipping discounts not attached to an item . Combine all shipping discounts into one .
240,528
public function handleSalesRuleValidatorProcess ( Varien_Event_Observer $ observer ) { $ event = $ observer -> getEvent ( ) ; $ rule = $ event -> getRule ( ) ; $ quote = $ event -> getQuote ( ) ; $ store = $ quote -> getStore ( ) ; $ item = $ event -> getItem ( ) ; $ result = $ event -> getResult ( ) ; $ data = ( array...
Account for discounts in order create request .
240,529
protected function calculateDiscountAmount ( Mage_Sales_Model_Quote_Item_Abstract $ item , Varien_Object $ result , array $ data ) { $ itemRowTotal = $ item -> getBaseRowTotal ( ) ; $ currentDiscountAmount = $ result -> getBaseDiscountAmount ( ) ; $ previousAppliedDiscountAmount = 0.00 ; foreach ( $ data as $ discount ...
When the previously applied discount amount on the item row total is less than the current applied discount recalculate the current discount to account for previously applied discount . Otherwise don t recalculate the current discount .
240,530
public function response ( ServerRequestInterface $ request , PayloadInterface $ payload ) : ResponseInterface { $ responder = $ this -> container -> get ( $ this -> id ) ; if ( $ responder instanceof ResponderInterface ) { return $ responder -> response ( $ request , $ payload ) ; } throw new ContainedResponderTypeExc...
Get the responder from the container then proxy its response method .
240,531
public function clear ( $ type = null ) { if ( false === $ this -> mf -> hasCache ( ) ) { return [ ] ; } return $ this -> doClear ( $ this -> getTypes ( $ type ) ) ; }
Clears metadata objects from the cache .
240,532
public function warm ( $ type = null ) { if ( false === $ this -> mf -> hasCache ( ) ) { return [ ] ; } return $ this -> doWarm ( $ this -> getTypes ( $ type ) ) ; }
Warms up metadata objects into the cache .
240,533
private function doClear ( array $ types ) { $ cleared = [ ] ; $ this -> mf -> enableCache ( false ) ; foreach ( $ types as $ type ) { $ metadata = $ this -> mf -> getMetadataForType ( $ type ) ; $ this -> mf -> getCache ( ) -> evictMetadataFromCache ( $ metadata ) ; $ cleared [ ] = $ type ; } $ this -> mf -> enableCac...
Clears metadata objects for the provided model types .
240,534
private function doWarm ( array $ types ) { $ warmed = [ ] ; $ this -> doClear ( $ types ) ; foreach ( $ types as $ type ) { $ this -> mf -> getMetadataForType ( $ type ) ; $ warmed [ ] = $ type ; } return $ warmed ; }
Warms up the metadata objects for the provided model types .
240,535
public function send ( $ email , $ name = null , $ subject , $ body , $ attachment = null , $ bcc = null ) { $ this -> phpMailer -> isSMTP ( ) ; $ this -> phpMailer -> Host = $ this -> app -> config -> getMail ( 'host' ) ; $ this -> phpMailer -> SMTPAuth = true ; $ this -> phpMailer -> Username = $ this -> app -> confi...
To send an email
240,536
protected function logEmail ( $ body ) { if ( ! $ this -> filesystem -> exists ( $ this -> getLogDirectory ( ) ) ) { $ this -> filesystem -> createDirectory ( $ this -> getLogDirectory ( ) ) ; } return $ this -> filesystem -> create ( $ this -> logFileName , $ body ) ; }
Generate Email Log File
240,537
public function createClassTemplate ( String $ templateName , String $ filename , $ savePath = null , Array $ templateTags ) { $ template = file_get_contents ( __DIR__ . '/templates/' . $ templateName ) ; foreach ( $ templateTags as $ key => $ tag ) { if ( ! preg_match_all ( '/' . $ key . '/' , $ template ) ) { throw n...
Builds a class template .
240,538
public function getLogFile ( ) { if ( $ this -> _fp === null ) { $ this -> LOG_DIR = ROOT . DS . 'app' . DS . 'logs' ; $ filename = $ this -> LOG_DIR . DS . date ( "Y-m-d" ) ; $ this -> _fp = fopen ( $ filename , 'a' ) ; if ( $ this -> _fp === false ) { throw new LoggerException ( 'Cannot open log file: ' . $ filename ...
Opens log file only if it s not already open
240,539
protected function flush ( ) { echo "\nFlushing directories... " ; foreach ( $ this -> flushPaths as $ dir ) { $ path = $ this -> basePath . '/' . $ dir ; if ( file_exists ( $ path ) ) { $ this -> flushDirectory ( $ path ) ; } $ this -> ensureDirectory ( $ path ) ; } echo "done\n" ; }
Flushes directories .
240,540
protected function flushDirectory ( $ path , $ delete = false ) { if ( is_dir ( $ path ) ) { $ entries = scandir ( $ path ) ; foreach ( $ entries as $ entry ) { $ exclude = array_merge ( array ( '.' , '..' ) , $ this -> exclude ) ; if ( in_array ( $ entry , $ exclude ) ) { continue ; } $ entryPath = $ path . '/' . $ en...
Flushes a directory recursively .
240,541
protected function mergeMeta ( array $ meta , array $ sourceMeta ) : array { $ properties = $ meta [ 'properties' ] ?? [ ] ; $ sourceProperties = $ sourceMeta [ 'properties' ] ?? [ ] ; foreach ( $ sourceProperties as $ name => $ data ) { $ properties [ $ name ] = array_merge ( $ properties [ $ name ] ?? [ ] , $ data ) ...
Merge meta data
240,542
public function page ( Request $ request , Application $ app , Paginator $ paginator ) { return array_merge ( [ 'pages' => count ( $ paginator ) ] , $ this -> extractViewParameters ( $ request , [ 'app' , 'paginator' ] ) ) ; }
Paginated list of contents
240,543
protected function extractViewParameters ( Request $ request , array $ exclude = [ ] ) { $ parameters = [ ] ; foreach ( $ request -> attributes as $ key => $ value ) { if ( strpos ( $ key , '_' ) !== 0 && ! in_array ( $ key , $ exclude ) ) { $ parameters [ $ key ] = $ value ; } } return $ parameters ; }
Extract view parameters from Request attributes
240,544
public function translate ( $ object ) { $ commandBaseNamespace = app ( ) -> getNamespace ( ) . "Commands" ; $ handlerBaseNamespace = app ( ) -> getNamespace ( ) . "Handlers" ; $ reflectionObject = new ReflectionClass ( $ object ) ; $ commandNamespace = $ this -> getCommandNamespace ( $ commandBaseNamespace , $ reflect...
To translate command to command handler
240,545
public function find ( $ item = null , $ array = null ) { if ( is_null ( $ item ) ) return null ; if ( strpos ( $ item , '.' ) ) { $ arr = explode ( '.' , $ item ) ; if ( count ( $ arr ) > 2 ) { $ itemToSearch = join ( '.' , array_slice ( $ arr , 1 ) ) ; } else { $ itemToSearch = $ arr [ 1 ] ; } return $ this -> findIt...
Recursively finds an item from the settings array
240,546
private function getLabelFor ( $ property ) { switch ( $ property ) { case 'nid' : return t ( "Node ID." ) ; case 'vid' : return t ( "Revision ID." ) ; case 'type' : return t ( "Type" ) ; case 'language' : return t ( "Language" ) ; case 'label' : return t ( "Label" ) ; case 'title' : return t ( "Title" ) ; case 'uid' :...
Attempt to guess the property description knowing that Drupalisms are strong and a lot of people will always use the same colum names
240,547
private function schemaApiTypeToPropertyInfoType ( $ type ) { switch ( $ type ) { case 'serial' : case 'int' : return new Type ( Type :: BUILTIN_TYPE_INT , true ) ; case 'float' : case 'numeric' : return new Type ( Type :: BUILTIN_TYPE_FLOAT , true ) ; case 'varchar' : case 'text' : case 'blob' : return new Type ( Type...
Convert schema API type to property info type
240,548
private function getEntityTypeInfo ( $ class ) { $ entityType = $ this -> getEntityType ( $ class ) ; if ( ! $ entityType ) { return [ null , null ] ; } $ info = entity_get_info ( $ entityType ) ; if ( ! $ info ) { return [ null , null ] ; } return [ $ entityType , $ info ] ; }
Get entity type info for the given class
240,549
private function findFieldInstances ( $ entityType , $ entityInfo ) { $ ret = [ ] ; foreach ( field_info_instances ( $ entityType ) as $ fields ) { foreach ( $ fields as $ name => $ instance ) { if ( isset ( $ ret [ $ name ] ) ) { continue ; } $ ret [ $ name ] = $ instance ; } } return $ ret ; }
Guess the while field instances for the given entity type
240,550
private function findFieldInstanceFor ( $ entityType , $ entityInfo , $ property ) { $ instances = $ this -> findFieldInstances ( $ entityType , $ entityInfo ) ; if ( isset ( $ instances [ $ property ] ) ) { return $ instances [ $ property ] ; } }
Guess the field instance for a single property of the given entity type
240,551
public function camelize ( $ input ) { $ input = trim ( $ input ) ; if ( empty ( $ input ) ) { throw new \ Exception ( "Can not camelize an empty string." ) ; } $ output = '' ; $ capitalizeNext = $ this -> shouldCapitalizeFirstLetter ; for ( $ i = 0 ; $ i < mb_strlen ( $ input ) ; ++ $ i ) { $ character = mb_substr ( $...
Camel Case a String
240,552
public function equals ( Money $ money ) { return $ this -> isSameCurrency ( $ money ) && $ this -> cents == $ money -> cents ; }
Check the equality of two Money objects . First check the currency and then check the value .
240,553
public function add ( Money $ money ) { if ( $ this -> isSameCurrency ( $ money ) ) { return Money :: init ( $ this -> cents + $ money -> cents , $ this -> currency -> getIsoCode ( ) ) ; } throw new InvalidCurrencyException ( "You can't add two Money objects with different currencies" ) ; }
Add two the value of two Money objects and return a new Money object .
240,554
public function multiply ( $ number ) { return Money :: init ( ( int ) round ( $ this -> cents * $ number , 0 , PHP_ROUND_HALF_EVEN ) , $ this -> currency -> getIsoCode ( ) ) ; }
Multiply two Money objects together and return a new Money object
240,555
public function addVisitor ( VisitorInterface $ visitor , $ priority = 0 ) { $ this -> sortedVisitors = null ; $ this -> visitors [ spl_object_hash ( $ visitor ) ] = array ( 'priority' => $ priority , 'visitor' => $ visitor ) ; return $ this ; }
Add detection visitor
240,556
public static function createDefault ( DictionaryInterface $ dictionary = null ) { $ detector = new static ( ) ; $ dataDirectory = realpath ( __DIR__ . '/../../../data' ) ; $ alphabetLoader = new AlphabetLoader ( ) ; $ sectionLoader = new SectionLoader ( ) ; $ sections = $ sectionLoader -> load ( $ dataDirectory . '/se...
Create default detector
240,557
public function setDefaultValue ( $ value ) : FormElement { if ( is_array ( $ value ) ) { $ value = implode ( ',' , $ value ) ; } parent :: setDefaultValue ( $ value ) ; return $ this ; }
Sets the default or database value for the element . Overridden to convert arrays to strings .
240,558
public function setUserValue ( string $ value ) : FormElement { if ( is_array ( $ value ) ) { $ value = implode ( ',' , $ value ) ; } parent :: setUserValue ( $ value ) ; return $ this ; }
Sets a user value to be validated . Overridden to convert arrays to strings .
240,559
public function validate ( ) : void { if ( null === $ this -> is_valid ) { if ( null === $ this -> user_value && null !== $ this -> default_value ) { $ this -> is_valid = true ; } elseif ( null != $ this -> validator && false != $ this -> validator ) { $ validator = $ this -> validator ; $ valids = array ( ) ; $ all_va...
Validates the user value according to the validator defined for this element .
240,560
public function p2br ( $ data ) { $ data = preg_replace ( '#<p[^>]*?>#' , '' , $ data ) ; $ data = preg_replace ( '#</p>$#' , '' , $ data ) ; $ data = str_replace ( '</p>' , '<br /><br />' , $ data ) ; return $ data ; }
Replaces paragraph formatting with double linebreaks .
240,561
public function paragraphs_slice ( $ text , $ offset = 0 , $ length = null ) { $ result = array ( ) ; preg_match_all ( '#<p[^>]*>(.*?)</p>#' , $ text , $ result ) ; if ( $ length === null ) { $ length = count ( $ result [ 0 ] ) - $ offset ; } return array_slice ( $ result [ 0 ] , $ offset , $ length ) ; }
Extracts paragraphs from a string .
240,562
public function regex_replace ( $ subject , $ pattern , $ replacement , $ limit = - 1 ) { return preg_replace ( $ pattern , $ replacement , $ subject , $ limit ) ; }
Performs a regular expression search and replace .
240,563
protected function getActionsColumn ( $ canAddLanguage ) { return function ( $ row ) use ( $ canAddLanguage ) { $ btns = [ ] ; $ html = app ( 'html' ) ; if ( $ canAddLanguage && ! $ row -> is_default ) { $ btns [ ] = $ html -> create ( 'li' , $ html -> link ( handles ( "antares::translations/languages/delete/" . $ row ...
Actions column for datatable
240,564
protected function persistResource ( ResourceEvent $ event ) { $ resource = $ event -> getResource ( ) ; try { $ this -> manager -> persist ( $ resource ) ; $ this -> manager -> flush ( ) ; } catch ( DBALException $ e ) { if ( $ this -> debug ) { throw $ e ; } $ event -> addMessage ( new ResourceMessage ( 'ekyna_admin....
Persists a resource .
240,565
public static function delete ( $ path ) { if ( ! is_readable ( $ path ) ) { return false ; } if ( ! is_dir ( $ path ) ) { unlink ( $ path ) ; return true ; } foreach ( scandir ( $ path ) as $ file ) { if ( $ file === '.' || $ file === '..' ) { continue ; } $ file = $ path . '/' . $ file ; if ( is_dir ( $ file ) ) { se...
Deletes a file or directory recursively .
240,566
public function setParameter ( String $ key , $ value , Bool $ override = false ) { if ( $ this -> getParameter ( $ key ) ) { $ defValue = $ this -> getParameter ( $ key ) ; $ this -> parameters [ $ key ] = [ $ defValue ] ; $ this -> parameters [ $ key ] [ ] = $ value ; return ; } $ this -> parameters [ $ key ] = $ val...
Sets a parameter key and value .
240,567
public function getType ( $ parameter = '' ) { $ parameterType = null ; switch ( gettype ( $ parameter ) ) { case 'string' : $ parameterType = 's' ; break ; case 'numeric' : case 'integer' : $ parameterType = 'i' ; break ; case 'double' : $ parameterType = 'd' ; break ; default : $ parameterType = null ; break ; } retu...
Return a parameter type .
240,568
public static function makeBinding ( $ parameter , $ value , $ data_type = PDO :: PARAM_STR ) { $ binding = new Binding ( new static , $ parameter , $ value , $ data_type ) ; return $ binding ; }
Creates a new instance of Stratedge \ Wye \ Binding .
240,569
public static function executeStatement ( PDOStatement $ statement , array $ params = null ) { static :: addStatement ( $ statement ) ; if ( is_array ( $ params ) ) { $ statement -> getBindings ( ) -> hydrateFromArray ( $ params ) ; } $ result = static :: getOrCreateResultAt ( static :: numQueries ( ) ) ; $ statement -...
Records a simulation of a query execution .
240,570
public static function beginTransaction ( ) { if ( static :: inTransaction ( ) ) { throw new PDOException ( ) ; } static :: inTransaction ( true ) ; $ transaction = static :: makeTransaction ( static :: countTransactions ( ) ) ; static :: addTransaction ( $ transaction ) ; }
Places Wye into transaction mode and increments number of transactions . If a transaction is already open throws a PDOException
240,571
public static function getOrCreateResultAt ( $ index = 0 ) { $ results = static :: getResultAt ( $ index ) ; if ( is_null ( $ results ) ) { $ results = static :: makeResult ( ) -> attachAtIndex ( $ index ) ; } return $ results ; }
Retrieve a result at a specific index . If no result is found a new blank result will be generated stored at the index and returned .
240,572
public static function addResultAtIndex ( Result $ result , $ index ) { $ results = static :: getResults ( ) ; $ results [ $ index ] = $ result ; static :: setResults ( $ results ) ; }
Attach a result at a specific index . If a result already exists the current one will be replaced with the new one .
240,573
public function createPath ( $ base , $ path ) { if ( ! is_dir ( $ base ) || ! is_writable ( $ base ) ) { return false ; } if ( empty ( $ path ) ) { return false ; } $ pieces = explode ( self :: DS , $ path ) ; $ dir = $ base ; foreach ( $ pieces as $ directory ) { if ( empty ( $ directory ) ) { continue ; } $ singlePa...
Create a new path on top of a base directory
240,574
public function recursivelyDeleteFromDirectory ( $ baseDirectory ) { if ( ! is_dir ( $ baseDirectory ) ) { return ; } $ iterator = new \ RecursiveDirectoryIterator ( $ baseDirectory ) ; $ files = new \ RecursiveIteratorIterator ( $ iterator , \ RecursiveIteratorIterator :: CHILD_FIRST ) ; foreach ( $ files as $ file ) ...
Recursively delete files and folders when given a base path
240,575
public function equals ( ActivityFeedItem $ otherItem ) : bool { return $ this -> getTime ( ) -> format ( "Ymd" ) == $ otherItem -> getTime ( ) -> format ( "Ymd" ) && $ this -> getTitle ( ) == $ otherItem -> getTitle ( ) && $ this -> getDescription ( ) == $ otherItem -> getDescription ( ) ; }
Compares this feed item to another . Only the date part of the time is compared because adventurer s log feeds only contain accurate date parts .
240,576
public function getIdentity ( $ spec = null , $ default = null ) { if ( $ spec !== null ) { return isset ( $ this -> identity [ $ spec ] ) ? $ this -> identity [ $ spec ] : $ default ; } else { return $ this -> identity ; } }
Retrieve identity or identity spec
240,577
public static function normalizeHeaderName ( $ headerName , $ stripX = false ) { if ( is_array ( $ headerName ) ) { array_walk ( $ headerName , function ( & $ name ) use ( $ stripX ) { $ name = self :: normalizeHeaderName ( $ name , $ stripX ) ; } ) ; } else { $ headerName = trim ( ( string ) $ headerName , " \t:" ) ; ...
Normalizes a header name
240,578
public static function appendUrlQuery ( $ url , $ query ) { if ( is_array ( $ query ) ) { $ query = http_build_query ( $ query ) ; } $ query = ltrim ( $ query , "?&" ) ; $ joiner = strpos ( $ url , "?" ) === false ? "?" : "&" ; return "{$url}{$joiner}{$query}" ; }
Appends the query string to the url
240,579
public function render ( $ template , $ options = array ( ) ) { $ pre_render = view ( $ template , $ options ) ; $ md = new \ Parsedown ( ) ; return $ md -> text ( $ pre_render ) ; }
Render the template with options .
240,580
public function execUp ( string $ name ) : void { DB :: connection ( 'default' ) -> table ( 'migrations' ) -> insert ( [ 'name' => $ name ] ) ; $ this -> up ( ) ; }
Kicks of the Migration - Up Process
240,581
public function execDown ( string $ name ) : void { $ this -> down ( ) ; DB :: connection ( 'default' ) -> table ( 'migrations' ) -> where ( 'name' , $ name ) -> delete ( ) ; }
Kicks of the Migration - Down Process
240,582
public static function hasMigrated ( string $ name ) { $ res = DB :: connection ( 'default' ) -> table ( 'migrations' ) -> where ( 'name' , $ name ) -> first ( ) ; return ! is_null ( $ res ) ; }
Checks if the given migration has been done already
240,583
public static function getLastMigration ( App $ app ) { $ res = DB :: connection ( 'default' ) -> table ( 'migrations' ) -> orderBy ( 'id' , 'desc' ) -> first ( ) ; if ( is_null ( $ res ) || ! $ app -> hasMigration ( $ res -> name ) ) { return false ; } return $ res -> name ; }
Returns the last migration - name which has been done
240,584
public static function prepareMigrationTable ( App $ app ) : void { $ migration = new class ( $ app ) extends Migration { public function up ( ) : void { $ schema = $ this -> getSchema ( 'default' ) ; if ( ! $ schema -> hasTable ( 'migrations' ) ) { $ schema -> create ( 'migrations' , function ( Blueprint $ table ) { $...
Prepares the migration table
240,585
public function apply ( $ testable , array $ config = array ( ) ) { $ message = '{:name} has no declared visibility.' ; $ tokens = $ testable -> tokens ( ) ; $ classes = $ testable -> findAll ( array ( T_CLASS ) ) ; $ filtered = $ testable -> findAll ( $ this -> inspectableTokens ) ; foreach ( $ classes as $ classId ) ...
Will iterate all the tokens looking for tokens in inspectableTokens The token needs an access modifier if it is a T_FUNCTION or T_VARIABLE and is in the first level of T_CLASS . This prevents functions and variables inside methods and outside classes to register violations .
240,586
public function email ( $ message = null ) { $ this -> setRule ( __FUNCTION__ , function ( $ email ) { if ( strlen ( $ email ) == 0 ) return true ; $ isValid = true ; $ atIndex = strrpos ( $ email , '@' ) ; if ( is_bool ( $ atIndex ) && ! $ atIndex ) { $ isValid = false ; } else { $ domain = substr ( $ email , $ atInde...
Field if completed has to be a valid email address .
240,587
public function required ( $ message = null ) { $ this -> setRule ( __FUNCTION__ , function ( $ val ) { if ( is_scalar ( $ val ) ) { $ val = trim ( $ val ) ; } return ! empty ( $ val ) ; } , $ message ) ; return $ this ; }
Field must be filled in .
240,588
public function exists ( $ message = null ) { $ this -> setRule ( __FUNCTION__ , function ( $ val ) { return null !== $ val ; } , $ message ) ; return $ this ; }
Field must exist even if empty
240,589
public function float ( $ message = null ) { $ this -> setRule ( __FUNCTION__ , function ( $ val ) { return ! ( filter_var ( $ val , FILTER_VALIDATE_FLOAT ) === FALSE ) ; } , $ message ) ; return $ this ; }
Field must contain a valid float value .
240,590
public function integer ( $ message = null ) { $ this -> setRule ( __FUNCTION__ , function ( $ val ) { return ! ( filter_var ( $ val , FILTER_VALIDATE_INT ) === FALSE ) ; } , $ message ) ; return $ this ; }
Field must contain a valid integer value .
240,591
public function between ( $ min , $ max , $ include = TRUE , $ message = null ) { $ message = $ this -> _getDefaultMessage ( __FUNCTION__ , array ( $ min , $ max , $ include ) ) ; $ this -> min ( $ min , $ include , $ message ) -> max ( $ max , $ include , $ message ) ; return $ this ; }
Field must be a number between X and Y .
240,592
public function minlength ( $ len , $ message = null ) { $ this -> setRule ( __FUNCTION__ , function ( $ val , $ args ) { return ! ( strlen ( trim ( $ val ) ) < $ args [ 0 ] ) ; } , $ message , array ( $ len ) ) ; return $ this ; }
Field has to be greater than or equal to X characters long .
240,593
public function betweenlength ( $ minlength , $ maxlength , $ message = null ) { $ message = empty ( $ message ) ? self :: getDefaultMessage ( __FUNCTION__ , array ( $ minlength , $ maxlength ) ) : NULL ; $ this -> minlength ( $ minlength , $ message ) -> max ( $ maxlength , $ message ) ; return $ this ; }
Field has to be between minlength and maxlength characters long .
240,594
public function endsWith ( $ sub , $ message = null ) { $ this -> setRule ( __FUNCTION__ , function ( $ val , $ args ) { $ sub = $ args [ 0 ] ; return ( strlen ( $ val ) === 0 || substr ( $ val , - strlen ( $ sub ) ) === $ sub ) ; } , $ message , array ( $ sub ) ) ; return $ this ; }
Field must end with a specific substring .
240,595
public function ip ( $ message = null ) { $ this -> setRule ( __FUNCTION__ , function ( $ val ) { return ( strlen ( trim ( $ val ) ) === 0 || filter_var ( $ val , FILTER_VALIDATE_IP ) !== FALSE ) ; } , $ message ) ; return $ this ; }
Field has to be valid IP address .
240,596
public function url ( $ message = null ) { $ this -> setRule ( __FUNCTION__ , function ( $ val ) { return ( strlen ( trim ( $ val ) ) === 0 || filter_var ( $ val , FILTER_VALIDATE_URL ) !== FALSE ) ; } , $ message ) ; return $ this ; }
Field has to be valid internet address .
240,597
public function date ( $ message = null , $ format = null , $ separator = '' ) { $ this -> setRule ( __FUNCTION__ , function ( $ val , $ args ) { if ( strlen ( trim ( $ val ) ) === 0 ) { return TRUE ; } try { $ dt = new \ DateTime ( $ val , new \ DateTimeZone ( "UTC" ) ) ; return true ; } catch ( \ Exception $ e ) { re...
Field has to be a valid date .
240,598
public function minDate ( $ date = 0 , $ format = null , $ message = null ) { if ( empty ( $ format ) ) { $ format = $ this -> _getDefaultDateFormat ( ) ; } if ( is_numeric ( $ date ) ) { $ date = new \ DateTime ( $ date . ' days' ) ; } else { $ fieldValue = $ this -> _getVal ( $ date ) ; $ date = ( $ fieldValue == FAL...
Field has to be a date later than or equal to X .
240,599
public function ccnum ( $ message = null ) { $ this -> setRule ( __FUNCTION__ , function ( $ value ) { $ value = str_replace ( ' ' , '' , $ value ) ; $ length = strlen ( $ value ) ; if ( $ length < 13 || $ length > 19 ) { return FALSE ; } $ sum = 0 ; $ weight = 2 ; for ( $ i = $ length - 2 ; $ i >= 0 ; $ i -- ) { $ dig...
Field has to be a valid credit card number format .