idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
35,000
public function remove ( $ sku ) { $ product = $ this -> pick ( $ sku ) ; $ this -> products -> remove ( $ sku ) ; }
Remove a product from the basket
35,001
public function postVerify ( $ area , Request $ request ) { $ area = app ( AreaManager :: class ) -> getById ( $ area ) ; return $ this -> processor -> verifyCredentials ( $ this , $ area , $ request -> input ( ) ) ; }
Post verify request .
35,002
static protected function create_connection ( $ name ) { if ( isset ( self :: $ _connections [ $ name ] ) ) return ; elseif ( self :: connectionExists ( $ name ) ) self :: $ _connections [ $ name ] = new Connection ( self :: $ _connection_data [ $ name ] , $ name ) ; else throw new Exception \ RuntimeException ( sprintf ( "Connection '%s' does not exist" , $ name ) ) ; }
Stablishes a connection from the available connections list .
35,003
static public function activeConnectionData ( ) { if ( ! self :: $ activeConnectionName ) throw new Exception \ RuntimeException ( "No database connection is active" ) ; return array_merge ( self :: $ _connection_data [ self :: $ activeConnectionName ] , [ 'name' => self :: $ activeConnectionName ] ) ; }
Returns active connection s data .
35,004
public function onIndex ( ) { $ this -> breadcrumbs -> register ( self :: $ name , function ( Generator $ breadcrumbs ) { $ breadcrumbs -> push ( 'General Configuration' ) ; } ) ; $ this -> shareOnView ( self :: $ name ) ; }
Register a breadcrumb on an admin index page .
35,005
public function getForDynamoDB ( ) { $ hash = $ this -> getHash ( ) ; $ range = $ this -> getRange ( ) ; $ parameters = array ( 'HashKeyElement' => $ hash -> getForDynamoDB ( ) ) ; if ( null !== $ range ) { $ parameters [ 'RangeKeyElement' ] = $ range -> getForDynamoDB ( ) ; } return $ parameters ; }
Return schema formated for DynamoDB
35,006
public static function getTypes ( array $ parameters ) { $ types = [ ] ; foreach ( $ parameters as $ parameter ) { $ types [ ] = PDOAbstract :: getType ( $ parameter ) ; } return $ types ; }
Returns an array of PDO type corresponding to the parameter array
35,007
public function findByLocaleAndFilter ( $ locale , array $ filter ) { try { $ qb = $ this -> getShippingQuery ( $ locale ) ; foreach ( $ filter as $ key => $ value ) { switch ( $ key ) { case 'status' : $ qb -> andWhere ( 'status.id = :' . $ key ) ; $ qb -> setParameter ( $ key , $ value ) ; break ; case 'orderId' : $ qb -> leftJoin ( 'shipping.order' , 'o' ) ; $ qb -> andWhere ( 'o.id = :' . $ key ) ; $ qb -> setParameter ( $ key , $ value ) ; break ; } } $ query = $ qb -> getQuery ( ) ; return $ query -> getResult ( ) ; } catch ( NoResultException $ ex ) { return null ; } }
Returns all shippings and filters them
35,008
public function findByOrderId ( $ id , $ locale = null ) { try { $ qb = $ this -> getShippingQuery ( $ locale ) ; $ qb -> andWhere ( 'shipping.order = :id' ) ; $ qb -> setParameter ( 'id' , $ id ) ; return $ qb -> getQuery ( ) -> getResult ( ) ; } catch ( NoResultException $ exc ) { return null ; } }
Finds a shipping by a order id
35,009
public function getSumOfShippedItemsByOrderId ( $ orderId , $ includeStatusDeliveryNote ) { try { $ qb = $ this -> createQueryBuilder ( 'shipping' ) -> select ( 'partial shipping.{id}, partial items.{id}, sum(shippingItems.quantity) AS shipped' ) -> leftJoin ( 'shipping.order' , 'o' , 'WITH' , 'o.id = :orderId' ) -> join ( 'o.items' , 'items' ) -> join ( 'shipping.status' , 'status' ) -> leftJoin ( 'shipping.shippingItems' , 'shippingItems' , 'WITH' , 'items = shippingItems.item' ) -> setParameter ( 'orderId' , $ orderId ) -> groupBy ( 'items.id' ) -> where ( 'status.id = :statusId' ) -> setParameter ( 'statusId' , ShippingStatus :: STATUS_SHIPPED ) ; if ( $ includeStatusDeliveryNote ) { $ qb -> orWhere ( 'status.id = :statusId2' ) -> setParameter ( 'statusId2' , ShippingStatus :: STATUS_DELIVERY_NOTE ) ; } return $ qb -> getQuery ( ) -> getScalarResult ( ) ; } catch ( NoResultException $ exc ) { return null ; } }
returns sum of items that are assigned to a shipping which is not in status created
35,010
public function getSumOfShippedItemsByItemId ( $ itemId , $ includeStatusDeliveryNote ) { try { $ qb = $ this -> createQueryBuilder ( 'shipping' ) -> select ( 'sum(shippingItems.quantity) AS shipped' ) -> join ( 'shipping.shippingItems' , 'shippingItems' ) -> join ( 'shippingItems.item' , 'item' , 'WITH' , 'item.id = :itemId' ) -> join ( 'shipping.status' , 'status' ) -> groupBy ( 'item.id' ) -> where ( 'status.id = :statusId' ) -> setParameter ( 'itemId' , $ itemId ) -> setParameter ( 'statusId' , ShippingStatus :: STATUS_SHIPPED ) ; if ( $ includeStatusDeliveryNote ) { $ qb -> orWhere ( 'status.id = :statusId2' ) -> setParameter ( 'statusId2' , ShippingStatus :: STATUS_DELIVERY_NOTE ) ; } return $ qb -> getQuery ( ) -> getSingleScalarResult ( ) ; } catch ( NoResultException $ exc ) { return null ; } }
returns all items that were shipped by itemId
35,011
private function getShippingQuery ( $ locale = null ) { $ qb = $ this -> createQueryBuilder ( 'shipping' ) -> leftJoin ( 'shipping.deliveryAddress' , 'deliveryAddress' ) -> leftJoin ( 'shipping.status' , 'status' ) -> leftJoin ( 'shipping.shippingItems' , 'shippingItems' ) -> leftJoin ( 'shippingItems.item' , 'items' ) ; if ( $ locale ) { $ qb -> leftJoin ( 'status.translations' , 'statusTranslations' , 'WITH' , 'statusTranslations.locale = :locale' ) -> setParameter ( 'locale' , $ locale ) ; } return $ qb ; }
Returns query for shippings
35,012
public function log ( $ model , $ row , $ user_id , $ action = 'created' ) { $ history = new History ; $ history -> hash = $ this -> makeUniqueHash ( $ this -> config -> table , 'hash' ) ; $ history -> table = $ model ; $ history -> row = $ row ; $ history -> user_id = $ user_id ; $ history -> crud_action = $ action ; $ history -> save ( ) ; }
Log an action to the database
35,013
protected function isLoaded ( $ table = null , $ database = null ) { if ( is_null ( $ table ) ) { if ( ! $ this -> table ) { return false ; } $ table = $ this -> table ; } if ( is_null ( $ database ) ) { if ( ! $ this -> database ) { return false ; } $ database = $ this -> database ; } $ meta = $ this -> getMeta ( $ table , $ database ) ; return $ this -> isPrimarySet ( $ meta [ self :: PRIMARY ] ) ; }
Checks to see if the model is populated
35,014
protected function getMeta ( $ table , $ database ) { $ uid = spl_object_hash ( $ database ) ; if ( isset ( self :: $ meta [ $ uid ] [ $ table ] ) ) { return self :: $ meta [ $ uid ] [ $ table ] ; } $ columns = $ database -> getColumns ( $ table ) ; $ meta = array ( ) ; foreach ( $ columns as $ i => $ column ) { $ meta [ self :: COLUMNS ] [ $ column [ 'Field' ] ] = array ( 'type' => $ column [ 'Type' ] , 'key' => $ column [ 'Key' ] , 'default' => $ column [ 'Default' ] , 'empty' => $ column [ 'Null' ] == 'YES' ) ; if ( $ column [ 'Key' ] == 'PRI' ) { $ meta [ self :: PRIMARY ] [ ] = $ column [ 'Field' ] ; } } self :: $ meta [ $ uid ] [ $ table ] = $ meta ; return $ meta ; }
Returns the table meta data
35,015
public static function createDefault ( ) : self { return new self ( [ new Type ( "any" , "[^/]+" ) , new Type ( "alnum" , "[a-zA-Z0-9]+" ) , new Type ( "alpha" , "[a-zA-Z]+" ) , new Type ( "date" , "\d{4}-\d{2}-\d{2}" ) , new Type ( "digit" , "\d" ) , new Type ( "number" , "\d+" ) , new Type ( "word" , "\w+" ) , ] ) ; }
Creates a collection with the default types .
35,016
public function run ( $ time = null ) { if ( empty ( $ this -> jobs ) ) return ; if ( $ time === null ) $ time = time ( ) ; $ date = getdate ( $ time ) ; $ count = 0 ; foreach ( $ this -> jobs as $ job ) { $ result = $ job -> run ( $ date ) ; if ( $ result ) $ count ++ ; } return $ count ; }
Find any execute any jobs set to run
35,017
public function setFinal ( $ final ) { if ( $ final === true ) { $ this -> addModifier ( Modifiers :: MODIFIER_FINAL ) ; } else { $ this -> removeModifier ( Modifiers :: MODIFIER_FINAL ) ; } }
Set the entity final modifier .
35,018
public function bind ( ) { if ( $ this -> providersLoaded ) { return $ this ; } $ this -> providers = new ProvidersCollection ( $ this -> providersRepository -> all ( ) ) ; foreach ( $ this -> providerGateways as & $ providerGateway ) { $ providers = $ this -> providers -> filterByGatewayName ( $ providerGateway -> getName ( ) ) ; foreach ( $ providers as & $ provider ) { $ provider -> setProviderGateway ( $ providerGateway ) ; } } $ this -> providersLoaded = true ; return $ this ; }
Bind gateways with providers models .
35,019
public function getProviderGatewayByName ( $ name ) { foreach ( $ this -> providerGateways as $ provider ) { if ( $ provider -> getName ( ) === $ name ) { return $ provider ; } } return null ; }
Returns the provider gateway by the given name .
35,020
public function getAreaProvidersCollection ( ) { $ collection = new Collection ; foreach ( $ this -> providers as $ model ) { $ area = $ this -> areaManager -> getById ( $ model -> area ) ; if ( is_null ( $ area ) ) { continue ; } $ areaProviders = $ collection -> get ( $ area -> getId ( ) ) ; if ( $ areaProviders === null ) { $ areaProviders = new AreaProviders ( $ area ) ; $ areaProviders -> addModel ( $ model ) ; $ collection -> put ( $ area -> getId ( ) , $ areaProviders ) ; } else { $ areaProviders -> addModel ( $ model ) ; } } return $ collection ; }
Returns the collection with areas and providers for each one .
35,021
public function getEnabledInArea ( AreaContract $ area ) { $ providers = $ this -> providers -> filterByArea ( $ area -> getId ( ) ) ; foreach ( $ providers as $ provider ) { if ( $ provider -> isEnabled ( ) ) { return $ provider ; } } return null ; }
Returns the enabled provider for the given area .
35,022
public function isRequiredInArea ( AreaContract $ area ) { $ enabledProvider = $ this -> getEnabledInArea ( $ area ) ; if ( $ enabledProvider === null ) { return false ; } return $ enabledProvider -> isForced ( ) ; }
Check if authentication is required for the given area .
35,023
public function getForDynamoDB ( ) { if ( $ this -> isArray ( ) ) { $ value = array_map ( function ( $ val ) { return strval ( $ val ) ; } , $ this -> getValue ( ) ) ; } else { $ value = strval ( $ this -> getValue ( ) ) ; } return array ( $ this -> getType ( ) => $ value ) ; }
Return attribute formated for DynamoDB
35,024
private function autoDetectType ( $ value ) { if ( is_array ( $ value ) ) { foreach ( $ value as $ val ) { if ( ! is_numeric ( $ val ) ) { return Type :: STRING_SET ; } } return Type :: NUMBER_SET ; } elseif ( is_numeric ( $ value ) ) { return Type :: NUMBER ; } else { return Type :: STRING ; } }
Auto detect attribute type base on value type
35,025
public function write ( $ directory = null ) { $ file = $ this -> getFilename ( ) ; if ( $ directory === null ) { $ directory = dirname ( $ file ) ; $ file = basename ( $ file ) ; } $ file = $ directory . DIRECTORY_SEPARATOR . $ file ; if ( is_writable ( $ directory ) !== true ) { throw new RuntimeException ( 'The file "' . $ file . '" is not writable.' ) ; } file_put_contents ( $ file , $ this -> generate ( ) ) ; return $ this ; }
Write the code to the file .
35,026
private function addProductZero ( Basket $ basket ) { $ zero = $ this -> products -> zero ( ) ; $ basket -> add ( $ zero -> sku , $ zero -> name , $ zero -> price ) ; return $ basket ; }
Add Product Zero
35,027
private function addProductOne ( Basket $ basket ) { $ one = $ this -> products -> one ( ) ; $ basket -> add ( $ one -> sku , $ one -> name , $ one -> price , function ( $ product ) use ( $ one ) { $ product -> category ( $ one -> category ) ; } ) ; return $ basket ; }
Add Product One
35,028
private function addProductTwo ( Basket $ basket ) { $ two = $ this -> products -> two ( ) ; $ basket -> add ( $ two -> sku , $ two -> name , $ two -> price , function ( $ product ) use ( $ two ) { $ product -> quantity ( $ two -> quantity ) ; } ) ; return $ basket ; }
Add Product Two
35,029
private function addProductThree ( Basket $ basket ) { $ three = $ this -> products -> three ( ) ; $ basket -> add ( $ three -> sku , $ three -> name , $ three -> price , function ( $ product ) use ( $ three ) { $ product -> freebie ( $ three -> freebie ) ; } ) ; return $ basket ; }
Add Product Three
35,030
private function addProductFour ( Basket $ basket ) { $ four = $ this -> products -> four ( ) ; $ basket -> add ( $ four -> sku , $ four -> name , $ four -> price , function ( $ product ) use ( $ four ) { $ product -> discount ( $ four -> discount ) ; } ) ; return $ basket ; }
Add Product Four
35,031
private function addProductFive ( Basket $ basket ) { $ five = $ this -> products -> five ( ) ; $ basket -> add ( $ five -> sku , $ five -> name , $ five -> price , function ( $ product ) use ( $ five ) { $ product -> discount ( $ five -> discount ) ; } ) ; return $ basket ; }
Add Product Five
35,032
private function addProductSix ( Basket $ basket ) { $ six = $ this -> products -> six ( ) ; $ basket -> add ( $ six -> sku , $ six -> name , $ six -> price , function ( $ product ) use ( $ six ) { $ product -> delivery ( $ six -> delivery ) ; } ) ; return $ basket ; }
Add Product Six
35,033
private function addProductSeven ( Basket $ basket ) { $ seven = $ this -> products -> seven ( ) ; $ basket -> add ( $ seven -> sku , $ seven -> name , $ seven -> price , function ( $ product ) use ( $ seven ) { $ product -> quantity ( $ seven -> quantity ) ; $ product -> discount ( $ seven -> discount ) ; $ product -> delivery ( $ seven -> delivery ) ; } ) ; return $ basket ; }
Add Product Seven
35,034
private function addProductEight ( Basket $ basket ) { $ eight = $ this -> products -> eight ( ) ; $ basket -> add ( $ eight -> sku , $ eight -> name , $ eight -> price , function ( $ product ) use ( $ eight ) { $ product -> quantity ( $ eight -> quantity ) ; $ product -> taxable ( $ eight -> taxable ) ; $ product -> delivery ( $ eight -> delivery ) ; } ) ; return $ basket ; }
Add Product Eight
35,035
private function addProductNine ( Basket $ basket ) { $ nine = $ this -> products -> nine ( ) ; $ basket -> add ( $ nine -> sku , $ nine -> name , $ nine -> price , function ( $ product ) use ( $ nine ) { $ product -> quantity ( $ nine -> quantity ) ; $ product -> freebie ( $ nine -> freebie ) ; $ product -> delivery ( $ nine -> delivery ) ; } ) ; return $ basket ; }
Add Product Nine
35,036
public function populateFromDynamoDB ( array $ data ) { foreach ( $ data as $ name => $ value ) { list ( $ type , $ value ) = each ( $ value ) ; $ this -> setAttribute ( $ name , $ value , $ type ) ; } }
Populate attributes from the raw DynamoDB response
35,037
public function getArrayCopy ( ) { $ attributes = array ( ) ; foreach ( $ this -> attributes as $ key => $ attribute ) { $ attributes [ $ key ] = $ attribute -> getValue ( ) ; } return $ attributes ; }
Return an Array representation of the item attributes
35,038
protected function generateFreeSpace ( ) { $ result = $ this -> formatAgencyAccount ( ) . $ this -> formatOurNumber ( ) . $ this -> title -> assignment -> wallet -> operation . '000' ; return $ result ; }
Free space defined by Bank .
35,039
protected function drawBillet ( ) { $ wallet = $ this -> title -> assignment -> wallet ; $ this -> fields [ 'wallet' ] [ 'value' ] = $ wallet -> operation ; parent :: drawBillet ( ) ; }
Banco do Banese requires the wallet field to be the wallet operation
35,040
public function save ( ) { $ event = $ this -> isSaved ( ) ? 'Update' : 'Create' ; $ mapper = Pheasant :: instance ( ) -> mapperFor ( $ this ) ; $ this -> events ( ) -> wrap ( array ( $ event , 'Save' ) , $ this , function ( $ obj ) use ( $ mapper ) { $ mapper -> save ( $ obj ) ; $ obj -> markSaved ( true ) -> clearChanges ( ) ; } ) ; return $ this ; }
Saves the domain object via the associated mapper
35,041
public function changes ( ) { $ changes = array ( ) ; foreach ( array_unique ( $ this -> _changed ) as $ key ) $ changes [ $ key ] = $ this -> get ( $ key , false ) ; return $ changes ; }
Returns a key = > val array of properties that have changed since the last save
35,042
public function delete ( ) { $ mapper = Pheasant :: instance ( ) -> mapperFor ( $ this ) ; $ this -> events ( ) -> wrap ( array ( 'Delete' ) , $ this , function ( $ obj ) use ( $ mapper ) { $ mapper -> delete ( $ obj ) ; $ obj -> markSaved ( false ) -> clearChanges ( ) ; } ) ; return $ this ; }
Deletes the domain object via the associated mapper
35,043
public function toArray ( ) { $ array = array ( ) ; foreach ( $ this -> _data as $ key => $ value ) $ array [ $ key ] = ( $ value instanceof PropertyReference ) ? $ value -> value ( ) : $ value ; return $ array ; }
Returns the object as an array
35,044
public function transaction ( $ closure , $ execute = true ) { $ transaction = static :: connection ( ) -> transaction ( ) ; $ transaction -> callback ( $ closure , $ this ) ; if ( $ execute ) $ transaction -> execute ( ) ; return $ transaction ; }
Creates a transaction passes the instance
35,045
public function lock ( $ onChanged = null ) { $ lock = new Locking \ PessimisticLock ( $ this ) ; $ locked = $ lock -> acquire ( ) ; if ( is_callable ( $ onChanged ) && ! $ locked -> equals ( $ this ) ) { call_user_func ( $ onChanged , $ this , $ locked ) ; } $ this -> _data = $ locked -> _data ; return $ this ; }
Creates a concurrency lock on the domain object with an optional closure to execute if the object has changed in the db when the lock finally provided . Closure gets the original and the new object
35,046
public function events ( $ events = array ( ) ) { if ( ! isset ( $ this -> _events ) ) { $ this -> _events = new Events ( array ( ) , self :: schema ( ) -> events ( ) ) ; $ this -> _registerDefaultEventHandlers ( ) ; } if ( count ( $ events ) ) foreach ( $ events as $ event => $ callback ) $ this -> _events -> register ( $ event , $ callback ) ; return $ this -> _events ; }
Returns the domain objects event collection optionally registering any passed events
35,047
public static function fromArray ( $ array = array ( ) ) { $ className = get_called_class ( ) ; $ object = unserialize ( sprintf ( 'O:%d:"%s":0:{}' , strlen ( $ className ) , $ className ) ) ; $ object -> _data = $ array ; $ object -> _saved = true ; return $ object ; }
Creates an instance from an array bypassing the constructor and setters
35,048
public static function import ( $ records ) { $ objects = array ( ) ; $ className = get_called_class ( ) ; $ defaults = self :: schema ( ) -> defaults ( ) ; foreach ( $ records as $ record ) { $ objects [ ] = $ className :: fromArray ( ) -> load ( array_merge ( $ defaults , $ record ) ) -> markSaved ( false ) -> save ( ) ; } return $ objects ; }
Creates and saves a array or arrays as domain objects
35,049
public function get ( $ prop ) { $ value = isset ( $ this -> _data [ $ prop ] ) ? $ this -> _data [ $ prop ] : null ; return $ value instanceof PropertyReference ? $ value -> value ( ) : $ value ; }
Gets a property
35,050
public function set ( $ prop , $ value ) { if ( ! isset ( $ this -> _data [ $ prop ] ) || $ this -> _data [ $ prop ] !== $ value ) { $ this -> _data [ $ prop ] = $ value ; $ this -> _changed [ ] = $ prop ; } return $ this ; }
Sets a property
35,051
public function load ( $ array , $ filter = false ) { if ( is_array ( $ filter ) ) { $ array = array_intersect_key ( $ array , array_fill_keys ( $ filter , NULL ) ) ; } foreach ( $ array as $ key => $ value ) { if ( is_object ( $ value ) || is_array ( $ value ) ) $ this -> $ key = $ value ; else $ this -> __set ( $ key , $ value ) ; } return $ this ; }
Loads an array of values into the object
35,052
public function reload ( ) { $ fresh = \ Pheasant :: instance ( ) -> finderFor ( $ this ) -> find ( $ this -> className ( ) , $ this -> identity ( ) -> toCriteria ( ) ) -> one ( ) ; $ this -> _data = $ fresh -> _data ; return $ this ; }
Reloads the contents of the object
35,053
protected function getConfig ( $ item ) { if ( ! is_null ( Config :: get ( $ this -> configNamePrefix . $ this -> layout . '.' . $ item ) ) ) { return Config :: get ( $ this -> configNamePrefix . $ this -> layout . '.' . $ item ) ; } else { return Config :: get ( $ this -> configNamePrefix . $ item ) ; } }
Get an item from config returning default one if custom is null . Blank is considered as not null .
35,054
protected function setConfig ( $ item , $ value ) { if ( ! is_null ( Config :: get ( $ this -> configNamePrefix . $ this -> layout . '.' . $ item ) ) ) { return Config :: set ( $ this -> configNamePrefix . $ this -> layout . '.' . $ item , $ value ) ; } else { return Config :: set ( $ this -> configNamePrefix . $ item , $ value ) ; } }
Set an item for current request in default config if custom is null else in custom config .
35,055
public function render ( ) { return $ this -> tagCharset ( ) . $ this -> tagTitle ( ) . $ this -> tagDescription ( ) . $ this -> tagMeta ( ) . $ this -> tagLink ( ) . $ this -> tagScript ( ) . $ this -> tagMisc ( ) ; }
Render all tags manually or automatically defined for filling head section . Empty values don t return any tag .
35,056
protected function tagCharset ( ) { $ charset = ( $ this -> charset ) ? $ this -> charset : $ this -> getConfig ( 'charset' ) ; if ( $ charset ) { return '<meta charset="' . $ charset . '">' . "\n\t" ; } }
Render meta charset tag .
35,057
protected function renderTitle ( ) { $ sitename = $ this -> getConfig ( 'title.sitename' ) ; $ title = ( $ this -> title ) ? $ this -> title : $ sitename ; $ separator = $ this -> getConfig ( 'title.separator' ) ; $ show = $ this -> getConfig ( 'title.show_sitename' ) ; $ first = $ this -> getConfig ( 'title.first' ) ; if ( $ show ) { if ( $ sitename == $ title ) { return $ sitename ; } elseif ( ! $ sitename ) { return $ title ; } elseif ( ! $ title ) { return $ sitename ; } else { return ( $ first ) ? $ title . $ separator . $ sitename : $ sitename . $ separator . $ title ; } } else { return $ title ; } }
Return the complete value for title .
35,058
protected function tagDescription ( ) { $ description = ( $ this -> description ) ? $ this -> description : $ this -> getConfig ( 'description' ) ; if ( $ description ) { return '<meta name="description" content="' . $ description . '">' . "\n\t" ; } }
Render description meta tag .
35,059
protected function tagMeta ( ) { $ html = '' ; $ this -> addRobots ( ) ; $ this -> addIeEdge ( ) ; $ this -> addResponsive ( ) ; $ this -> addFacebook ( ) ; $ this -> addTwitter ( ) ; foreach ( $ this -> meta as $ type => $ val ) { foreach ( $ val as $ value => $ content ) { if ( $ value && $ content ) { if ( File :: isFile ( public_path ( $ content ) ) ) { $ content = asset ( $ content ) ; } $ html .= '<meta ' . $ type . '="' . $ value . '" content="' . $ content . '">' . "\n\t" ; } } } return $ html ; }
Render all meta tags .
35,060
public function addMeta ( $ meta = array ( ) ) { foreach ( $ meta as $ type => $ value ) { $ this -> meta [ $ type ] = array_merge ( $ this -> meta [ $ type ] , $ value ) ; } }
Register several meta tags .
35,061
protected function addFacebook ( ) { $ sitename = $ this -> getConfig ( 'title.sitename' ) ; $ title = $ this -> renderTitle ( ) ; $ description = ( $ this -> description ) ? $ this -> description : $ this -> getConfig ( 'description' ) ; $ admins = $ this -> getConfig ( 'facebook.admins' ) ; $ page_id = $ this -> getConfig ( 'facebook.page_id' ) ; $ app_id = $ this -> getConfig ( 'facebook.app_id' ) ; $ image = $ this -> getConfig ( 'facebook.image' ) ; if ( $ this -> getConfig ( 'facebook.active' ) ) { if ( ! array_key_exists ( 'fb:page_id' , $ this -> meta [ 'property' ] ) ) { $ this -> addOneMeta ( 'property' , 'fb:page_id' , $ page_id ) ; } if ( ! array_key_exists ( 'fb:app_id' , $ this -> meta [ 'property' ] ) ) { $ this -> addOneMeta ( 'property' , 'fb:app_id' , $ app_id ) ; } if ( ! array_key_exists ( 'fb:admins' , $ this -> meta [ 'property' ] ) ) { $ this -> addOneMeta ( 'property' , 'fb:admins' , $ admins ) ; } if ( File :: isFile ( public_path ( $ image ) ) && ! array_key_exists ( 'og:image' , $ this -> meta [ 'property' ] ) ) { $ this -> addOneMeta ( 'property' , 'og:image' , $ image ) ; } if ( ! array_key_exists ( 'og:url' , $ this -> meta [ 'property' ] ) ) { $ this -> addOneMeta ( 'property' , 'og:url' , URL :: current ( ) ) ; } if ( ! array_key_exists ( 'og:type' , $ this -> meta [ 'property' ] ) ) { $ this -> addOneMeta ( 'property' , 'og:type' , 'website' ) ; } if ( ! array_key_exists ( 'og:site_name' , $ this -> meta [ 'property' ] ) ) { $ this -> addOneMeta ( 'property' , 'og:site_name' , $ sitename ) ; } if ( ! array_key_exists ( 'og:title' , $ this -> meta [ 'property' ] ) ) { $ this -> addOneMeta ( 'property' , 'og:title' , $ title ) ; } if ( ! array_key_exists ( 'og:description' , $ this -> meta [ 'property' ] ) ) { $ this -> addOneMeta ( 'property' , 'og:description' , $ description ) ; } } else { $ this -> killFacebook ( ) ; } }
Register Open Graph meta tags .
35,062
protected function addTwitter ( ) { $ title = $ this -> renderTitle ( ) ; $ description = ( $ this -> description ) ? $ this -> description : $ this -> getConfig ( 'description' ) ; $ image = $ this -> getConfig ( 'twitter.image' ) ; $ site = $ this -> getConfig ( 'twitter.site' ) ; $ creator = $ this -> getConfig ( 'twitter.creator' ) ; if ( $ this -> getConfig ( 'twitter.active' ) ) { if ( ! array_key_exists ( 'twitter:card' , $ this -> meta [ 'name' ] ) ) { $ this -> addOneMeta ( 'name' , 'twitter:card' , 'summary' ) ; } if ( ! array_key_exists ( 'twitter:title' , $ this -> meta [ 'name' ] ) ) { $ this -> addOneMeta ( 'name' , 'twitter:title' , $ title ) ; } if ( ! array_key_exists ( 'twitter:description' , $ this -> meta [ 'name' ] ) ) { $ this -> addOneMeta ( 'name' , 'twitter:description' , $ description ) ; } if ( File :: isFile ( public_path ( $ image ) ) && ! array_key_exists ( 'twitter:image:src' , $ this -> meta [ 'name' ] ) ) { $ this -> addOneMeta ( 'name' , 'twitter:image:src' , $ image ) ; } if ( ! array_key_exists ( 'twitter:site' , $ this -> meta [ 'name' ] ) ) { $ this -> addOneMeta ( 'name' , 'twitter:site' , $ site ) ; } if ( ! array_key_exists ( 'twitter:creator' , $ this -> meta [ 'name' ] ) ) { $ this -> addOneMeta ( 'name' , 'twitter:creator' , $ creator ) ; } if ( ! array_key_exists ( 'twitter:url' , $ this -> meta [ 'name' ] ) ) { $ this -> addOneMeta ( 'name' , 'twitter:url' , URL :: current ( ) ) ; } } else { $ this -> killTwitter ( ) ; } }
Register Twitter Card meta tags .
35,063
protected function killTwitter ( ) { foreach ( $ this -> meta as $ type => $ val ) { foreach ( $ val as $ value => $ content ) { if ( starts_with ( $ value , 'twitter:' ) || starts_with ( $ value , 'twitter:' ) ) { $ this -> meta [ 'name' ] = array_except ( $ this -> meta [ 'name' ] , array ( $ value ) ) ; } } } }
Remove all Twitter Card tags set manually .
35,064
protected function tagLink ( ) { $ html = '' ; $ this -> addFavicon ( ) ; $ this -> addStyleSheets ( ) ; foreach ( $ this -> link as $ link ) { if ( array_key_exists ( 1 , $ link ) && $ link [ 1 ] && array_key_exists ( 0 , $ link ) && $ link [ 0 ] ) { $ start_cond = '' ; $ end_cond = '' ; $ type = '' ; $ attr = '' ; if ( array_key_exists ( 4 , $ link ) && $ link [ 4 ] ) { $ start_cond = '<!--[if ' . $ link [ 4 ] . ']>' ; $ end_cond = '<![endif] ; } if ( array_key_exists ( 3 , $ link ) && is_array ( $ link [ 3 ] ) ) { foreach ( $ link [ 3 ] as $ name => $ content ) { if ( $ name && $ content ) { $ attr .= ' ' . $ name . '="' . $ content . '"' ; } } } if ( array_key_exists ( 2 , $ link ) && $ link [ 2 ] ) { $ type = ' type="' . $ link [ 2 ] . '"' ; } $ html .= $ start_cond . '<link rel="' . $ link [ 0 ] . '" href="' . $ link [ 1 ] . '"' . $ type . $ attr . '>' . $ end_cond . "\n\t" ; } } return $ html ; }
Render all link tags .
35,065
public function addOneLink ( $ rel , $ href , $ type = '' , $ attr = array ( ) , $ cond = '' ) { $ this -> addLink ( array ( array ( $ rel , $ href , $ type , $ attr , $ cond ) ) ) ; }
Register only one link tag .
35,066
protected function addFavicon ( ) { $ favicon = ( $ this -> favicon ) ? $ this -> favicon : $ this -> getConfig ( 'favicon' ) ; if ( $ favicon ) { if ( File :: exists ( public_path ( $ favicon . '.ico' ) ) ) { $ this -> addOneLink ( 'shortcut icon' , asset ( $ favicon . '.ico' ) ) ; $ this -> addOneLink ( 'icon' , asset ( $ favicon . '.ico' ) , 'image/x-icon' ) ; } if ( File :: exists ( public_path ( $ favicon . '.png' ) ) ) { $ this -> addOneLink ( 'icon' , asset ( $ favicon . '.png' ) , 'image/png' ) ; } } }
Register link tags for favicon .
35,067
protected function addStyleSheets ( ) { $ path = '' ; if ( $ this -> getConfig ( 'assets.paths.css' ) ) { $ path = $ this -> getConfig ( 'assets.paths.css' ) . '/' ; } foreach ( $ this -> stylesheets as $ file => $ options ) { $ media = 'all' ; $ cond = '' ; $ cdn = $ this -> getConfig ( 'assets.cdn.' . $ file ) ; $ href = '' ; if ( is_string ( $ options ) && $ options ) { $ media = $ options ; } elseif ( is_array ( $ options ) ) { if ( array_key_exists ( 1 , $ options ) && $ options [ 1 ] ) { $ cond = $ options [ 1 ] ; } if ( array_key_exists ( 0 , $ options ) && $ options [ 0 ] ) { $ media = $ options [ 0 ] ; } } if ( $ cdn ) { $ href = $ cdn ; } elseif ( File :: exists ( public_path ( $ path . $ file . '.css' ) ) ) { $ href = asset ( $ path . $ file . '.css' ) ; } if ( $ href ) { $ this -> addOneLink ( 'stylesheet' , $ href , '' , array ( 'media' => $ media ) , $ cond ) ; } } }
Register link tags for stylesheets .
35,068
public function addCss ( $ css = array ( ) ) { foreach ( $ css as $ file => $ options ) { $ this -> stylesheets = array_add ( $ this -> stylesheets , $ file , $ options ) ; } }
Register several stylesheets .
35,069
protected function tagScript ( ) { $ html = '' ; $ path = '' ; if ( $ this -> getConfig ( 'assets.paths.js' ) ) { $ path = $ this -> getConfig ( 'assets.paths.js' ) . '/' ; } foreach ( $ this -> scripts as $ file => $ options ) { $ start_cond = '' ; $ end_cond = '' ; $ load = '' ; $ cdn = $ this -> getConfig ( 'assets.cdn.' . $ file ) ; $ src = '' ; if ( is_string ( $ options ) && ( $ options == 'defer' || $ options == 'async' ) ) { $ load = ' ' . $ options ; } elseif ( is_array ( $ options ) ) { if ( array_key_exists ( 1 , $ options ) && $ options [ 1 ] ) { $ start_cond = '<!--[if ' . $ options [ 1 ] . ']>' ; $ end_cond = '<![endif] ; } if ( array_key_exists ( 0 , $ options ) && ( $ options [ 0 ] == 'defer' || $ options [ 0 ] == 'async' ) ) { $ load = ' ' . $ options [ 0 ] ; } } if ( $ cdn ) { $ src = $ cdn ; } elseif ( File :: exists ( public_path ( $ path . $ file . '.js' ) ) ) { $ src = asset ( $ path . $ file . '.js' ) ; } if ( $ src ) { $ html .= $ start_cond . '<script src="' . $ src . '"' . $ load . '></script>' . $ end_cond . "\n\t" ; } } return $ html ; }
Render all scripts .
35,070
public function addScript ( $ script = array ( ) ) { foreach ( $ script as $ file => $ options ) { $ this -> scripts = array_add ( $ this -> scripts , $ file , $ options ) ; } }
Register several scripts .
35,071
protected function tagMisc ( ) { $ html = '' ; $ this -> addShiv ( ) ; $ this -> addAnalytics ( ) ; foreach ( $ this -> misc as $ line ) { $ html .= $ line . "\n\t" ; } return $ html ; }
Render all additional items .
35,072
public function addMisc ( $ tag ) { if ( is_array ( $ tag ) ) { foreach ( $ tag as $ line ) { array_push ( $ this -> misc , $ line ) ; } } elseif ( is_string ( $ tag ) ) { array_push ( $ this -> misc , $ tag ) ; } }
Register additional items .
35,073
protected function addAnalytics ( ) { $ id = $ this -> getConfig ( 'analytics.id' ) ; $ script = $ this -> getConfig ( 'analytics.script' ) ; if ( App :: environment ( 'production' ) && $ this -> getConfig ( 'analytics.active' ) ) { if ( $ script ) { $ this -> addMisc ( '<script>' . $ script . '</script>' ) ; } elseif ( $ id ) { $ this -> addMisc ( "<script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga');ga('create', '" . $ id . "', 'auto');ga('send', 'pageview');</script>" ) ; } } }
Register analytics script .
35,074
public function skipToLeaves ( TreeVisitor $ visitor ) : void { $ leaves = $ this -> gatherLeaves ( ) ; foreach ( $ leaves as $ leaf ) { $ leaf -> accept ( $ visitor ) ; } }
Sends the visitor to the tree leaves skipping all intermediate nodes .
35,075
public static function get ( array $ array , $ keyPath ) { self :: checkKeyPathIsValidAndNonEmpty ( $ keyPath ) ; $ keys = self :: explodeKeys ( strval ( $ keyPath ) ) ; $ nextValue = null ; while ( $ keys !== array ( ) ) { $ key = array_shift ( $ keys ) ; if ( ! array_key_exists ( $ key , $ array ) ) { throw new KeyNotFound ( $ keyPath ) ; } $ nextValue = $ array [ $ key ] ; if ( ! is_array ( $ nextValue ) ) { break ; } $ array = $ nextValue ; } if ( $ keys === array ( ) ) { return $ nextValue ; } throw new KeyNotFound ( $ keyPath ) ; }
Get the dotted key path value from the array .
35,076
public static function has ( array $ array , $ keyPath ) { self :: checkKeyPathIsValidAndNonEmpty ( $ keyPath ) ; $ keys = self :: explodeKeys ( strval ( $ keyPath ) ) ; while ( $ keys !== array ( ) ) { $ key = array_shift ( $ keys ) ; if ( ! array_key_exists ( $ key , $ array ) ) { return false ; } $ array = $ array [ $ key ] ; if ( ! is_array ( $ array ) ) { break ; } } return $ keys === array ( ) ; }
Whether the array has the key .
35,077
public static function set ( array & $ array , $ keyPath , $ value ) { self :: checkKeyPathIsValidAndNonEmpty ( $ keyPath ) ; $ keys = self :: explodeKeys ( strval ( $ keyPath ) ) ; $ result = $ array ; $ ptr = & $ result ; $ parentKeys = array ( ) ; while ( $ keys !== array ( ) ) { $ key = array_shift ( $ keys ) ; $ parentKeys [ ] = $ key ; if ( ! array_key_exists ( $ key , $ ptr ) ) { $ ptr [ $ key ] = $ keys === array ( ) ? $ value : array ( ) ; $ ptr = & $ ptr [ $ key ] ; continue ; } $ ptr = & $ ptr [ $ key ] ; if ( $ keys === array ( ) ) { $ ptr = $ value ; break ; } elseif ( ! is_array ( $ ptr ) ) { throw new InconsistentKeyTypes ( $ ptr , array ( ) , implode ( '.' , $ parentKeys ) ) ; } } $ array = $ result ; }
Set the dotted key path in the array .
35,078
public static function setAndOverride ( array & $ array , $ keyPath , $ value ) { self :: checkKeyPathIsValidAndNonEmpty ( $ keyPath ) ; $ keys = self :: explodeKeys ( strval ( $ keyPath ) ) ; $ result = $ array ; $ ptr = & $ result ; while ( $ keys !== array ( ) ) { $ key = array_shift ( $ keys ) ; if ( ! array_key_exists ( $ key , $ ptr ) ) { $ ptr [ $ key ] = $ keys === array ( ) ? $ value : array ( ) ; $ ptr = & $ ptr [ $ key ] ; continue ; } $ ptr = & $ ptr [ $ key ] ; if ( $ keys === array ( ) ) { $ ptr = $ value ; break ; } elseif ( ! is_array ( $ ptr ) ) { $ ptr = array ( ) ; } } $ array = $ result ; }
Set the dotted key path in the array and return the value .
35,079
public static function remove ( array & $ array , $ keyPath ) { self :: checkKeyPathIsValidAndNonEmpty ( $ keyPath ) ; $ result = $ array ; $ keys = self :: explodeKeys ( strval ( $ keyPath ) ) ; $ ptr = & $ result ; while ( $ keys !== array ( ) ) { $ key = array_shift ( $ keys ) ; if ( ! array_key_exists ( $ key , $ ptr ) ) { $ ptr [ $ key ] = array ( ) ; $ ptr = & $ ptr [ $ key ] ; continue ; } $ prevPtr = & $ ptr ; $ ptr = & $ ptr [ $ key ] ; if ( $ keys === array ( ) ) { unset ( $ prevPtr [ $ key ] ) ; $ array = $ result ; return ; } elseif ( ! is_array ( $ ptr ) ) { throw new KeyNotFound ( $ keyPath ) ; } } throw new KeyNotFound ( $ keyPath ) ; }
Remove a value from a key path in an array and return the array .
35,080
public static function expand ( array $ array ) { $ result = array ( ) ; foreach ( $ array as $ key => $ value ) { $ references = self :: explodeKeys ( ( string ) $ key ) ; $ value = self :: expandValue ( $ value ) ; if ( count ( $ references ) === 1 ) { $ key = $ references [ 0 ] ; if ( array_key_exists ( $ key , $ result ) ) { $ result [ $ key ] = self :: mergeTwoValues ( $ result [ $ key ] , $ value , array ( $ key ) ) ; } else { $ result [ $ key ] = $ value ; } } else { self :: dereferenceDots ( $ result , $ references , $ value ) ; } } return $ result ; }
Convert a dot notation array to a normal PHP array recursively expanding the dotted keys .
35,081
private static function doCompact ( array $ array , $ integerKeysIncluded = true ) { $ result = array ( ) ; foreach ( $ array as $ key => $ value ) { $ escapedKey = self :: escapeKey ( $ key ) ; $ extraKeyPath = "" ; while ( self :: isCompactableArray ( $ value , $ integerKeysIncluded ) ) { $ nextValue = reset ( $ value ) ; $ compactKey = key ( $ value ) ; $ extraKeyPath .= "." . self :: escapeKey ( $ compactKey ) ; $ value = $ nextValue ; } $ result [ $ escapedKey . $ extraKeyPath ] = self :: compactValue ( $ value ) ; } return $ result ; }
Compact an expanded array to a DotNotation array .
35,082
private static function dereferenceDots ( & $ result , $ references , $ values ) { $ top = array_shift ( $ references ) ; $ ref = end ( $ references ) ; while ( key ( $ references ) !== null ) { $ values = array ( $ ref => $ values ) ; $ ref = prev ( $ references ) ; } if ( array_key_exists ( $ top , $ result ) ) { $ result [ $ top ] = self :: mergeTwoValues ( $ result [ $ top ] , $ values , array ( $ top ) ) ; } else { $ result [ $ top ] = $ values ; } }
Dereference an array of keys and append the result to an array .
35,083
private static function mergeArraysRecursively ( $ firstArray , $ secondArray , $ parentKeys ) { $ result = $ firstArray ; foreach ( $ secondArray as $ key => $ value ) { if ( array_key_exists ( $ key , $ firstArray ) ) { array_push ( $ parentKeys , $ key ) ; $ result [ $ key ] = self :: mergeTwoValues ( $ firstArray [ $ key ] , $ value , $ parentKeys ) ; array_pop ( $ parentKeys ) ; } else { $ result [ $ key ] = $ value ; } } return $ result ; }
Merge arrays recursively .
35,084
private static function mergeTwoValues ( $ originalValue , $ newValue , $ parentKeys ) { $ originalIsArray = is_array ( $ originalValue ) ; $ newIsArray = is_array ( $ newValue ) ; if ( $ originalIsArray && $ newIsArray ) { return self :: mergeArraysRecursively ( $ originalValue , $ newValue , $ parentKeys ) ; } elseif ( ! $ originalIsArray && ! $ newIsArray ) { return $ newValue ; } else { throw new InconsistentKeyTypes ( $ originalValue , $ newValue , implode ( '.' , $ parentKeys ) ) ; } }
Merge two values and return the result .
35,085
private static function checkKeyPathIsValidAndNonEmpty ( $ keyPath ) { if ( ! is_string ( $ keyPath ) && ! is_int ( $ keyPath ) ) { throw new BadKeyPath ( $ keyPath ) ; } if ( strlen ( strval ( $ keyPath ) ) === 0 ) { throw new BadKeyPath ( $ keyPath ) ; } }
Check the variable is a string .
35,086
private static function isCompactableArray ( $ value , $ integerKeysIncluded ) { if ( ! is_array ( $ value ) ) { return false ; } reset ( $ value ) ; $ firstKey = key ( $ value ) ; if ( ! $ integerKeysIncluded && self :: isInteger ( $ firstKey ) ) { return false ; } next ( $ value ) ; return key ( $ value ) === null ; }
Whether the array is compactable .
35,087
private static function explodeKeys ( $ keyPath ) { $ keys = explode ( '.' , $ keyPath ) ; if ( strpos ( $ keyPath , '\\.' ) === false ) { return array_filter ( $ keys , function ( $ elem ) { return $ elem !== '' ; } ) ; } $ joinNext = false ; $ result = array ( ) ; $ next = 0 ; foreach ( $ keys as $ index => $ key ) { $ len = strlen ( $ key ) ; if ( $ len === 0 ) { continue ; } $ endsWithBackslash = $ key [ $ len - 1 ] === '\\' ; if ( $ joinNext ) { $ result [ $ next - 1 ] = sprintf ( "%s.%s" , substr ( $ result [ $ next - 1 ] , 0 , - 1 ) , $ key ) ; $ joinNext = $ endsWithBackslash ; continue ; } elseif ( $ endsWithBackslash ) { $ joinNext = true ; } $ result [ $ next ] = $ key ; $ next += 1 ; } return $ result ; }
Explode the keys .
35,088
public function getRows ( ) { $ query = $ this -> getQuery ( ) ; if ( ! empty ( $ this -> columns ) ) { $ query -> select ( implode ( ', ' , $ this -> columns ) ) ; } foreach ( $ this -> sort as $ key => $ value ) { $ query -> sortBy ( $ key , $ value ) ; } if ( $ this -> range ) { $ query -> limit ( $ this -> start , $ this -> range ) ; } if ( ! empty ( $ this -> group ) ) { $ query -> groupBy ( $ this -> group ) ; } return $ this -> database -> query ( $ query , $ this -> database -> getBinds ( ) ) ; }
Returns the array rows
35,089
public function setRange ( $ range ) { Argument :: i ( ) -> test ( 1 , 'int' ) ; if ( $ range < 0 ) { $ range = 25 ; } $ this -> range = $ range ; return $ this ; }
Sets the pagination range
35,090
public function setStart ( $ start ) { Argument :: i ( ) -> test ( 1 , 'int' ) ; if ( $ start < 0 ) { $ start = 0 ; } $ this -> start = $ start ; return $ this ; }
Sets the pagination start
35,091
private function generateDecryptRequest ( InputInterface $ input , OutputInterface $ output ) { $ algorithmId = $ input -> getArgument ( 'algorithm_id' ) ; $ encryptedValue = $ input -> getArgument ( 'encrypted_value' ) ; $ key = $ input -> getOption ( 'key' ) ; $ keyProvided = $ input -> hasParameterOption ( [ '--key' , '-k' ] ) ; $ questionText = 'Encrypted value to be decrypted (hidden input): ' ; $ encryptedAsker = $ this -> questionAskerGenerator -> generateHiddenInputQuestionAsker ( $ questionText , $ input , $ output ) ; return $ this -> decryptRequestFactory -> createDecryptRequest ( $ algorithmId , $ encryptedAsker , $ encryptedValue , $ key , $ keyProvided ) ; }
Generate decrypt request .
35,092
public static function fromReflection ( ReflectionProperty $ reflectionProperty ) { $ pg = new static ( $ reflectionProperty -> getName ( ) ) ; if ( $ reflectionProperty -> getReflectionDocComment ( ) -> isEmpty ( ) !== true ) { $ pg -> setDocumentation ( DocCommentGenerator :: fromReflection ( $ reflectionProperty -> getReflectionDocComment ( ) ) ) ; } if ( $ reflectionProperty -> isDefault ( ) === true ) { $ defaultValue = $ reflectionProperty -> getDeclaringClass ( ) -> getDefaultProperties ( ) ; $ pg -> setDefaultValue ( $ defaultValue [ $ reflectionProperty -> getName ( ) ] ) ; } if ( $ reflectionProperty -> isStatic ( ) === true ) { $ pg -> setStatic ( true ) ; } if ( $ reflectionProperty -> isPrivate ( ) === true ) { $ pg -> setVisibility ( Modifiers :: VISIBILITY_PRIVATE ) ; } elseif ( $ reflectionProperty -> isProtected ( ) === true ) { $ pg -> setVisibility ( Modifiers :: VISIBILITY_PROTECTED ) ; } else { $ pg -> setVisibility ( Modifiers :: VISIBILITY_PUBLIC ) ; } return $ pg ; }
Create a new property generator from reflection .
35,093
protected function isNameValid ( $ name ) { if ( is_string ( $ name ) === false ) { return false ; } $ match = preg_match ( self :: PATTERN_VALIDATE_NAME , $ name ) ; if ( $ name === '' || $ match === false || $ match <= 0 ) { return false ; } else { return true ; } }
Check if the name is valid .
35,094
public function setDefaultValue ( $ value ) { if ( ( $ value instanceof ValueGenerator ) === false ) { $ value = new ValueGenerator ( $ value ) ; $ value -> setOutputMode ( ValueGenerator :: OUTPUT_SINGLE_LINE ) ; } if ( $ this -> isValidPropertyDefaultValue ( $ value ) !== true ) { throw new InvalidArgumentException ( 'Parameter default value is not valid.' ) ; } $ this -> defaultValue = $ value ; return $ this ; }
Set the default value for the property .
35,095
public function add ( $ column , $ operator , $ value , $ conjunction = 'AND' ) { if ( ! in_array ( $ operator , self :: $ arithmeticOperator ) ) { throw new InvalidArgumentException ( 'Invalid arithmetic operator (allowed: ' . implode ( ', ' , self :: $ arithmeticOperator ) . ')' ) ; } if ( ! in_array ( $ conjunction , self :: $ logicOperator ) ) { throw new InvalidArgumentException ( 'Invalid logic operator (allowed: ' . implode ( ', ' , self :: $ logicOperator ) . ')' ) ; } if ( $ operator == 'IN' && is_array ( $ value ) ) { $ expr = new Condition \ In ( $ column , $ value , $ conjunction ) ; } elseif ( ( $ operator == '=' || $ operator == 'IS' ) && $ value === null ) { $ expr = new Condition \ Nil ( $ column , $ conjunction ) ; } elseif ( ( $ operator == '!=' || $ operator == 'IS NOT' ) && $ value === null ) { $ expr = new Condition \ NotNil ( $ column , $ conjunction ) ; } else { $ expr = new Condition \ Basic ( $ column , $ operator , $ value , $ conjunction ) ; } return $ this -> addExpression ( $ expr ) ; }
Adds a condition and tries to detect the type of the condition based on the provided values . It is recommended to use an explicit method
35,096
public function equals ( $ column , $ value , $ conjunction = 'AND' ) { return $ this -> addExpression ( new Condition \ Basic ( $ column , '=' , $ value , $ conjunction ) ) ; }
Asserts that the column is equals to the value
35,097
public function notEquals ( $ column , $ value , $ conjunction = 'AND' ) { return $ this -> addExpression ( new Condition \ Basic ( $ column , '!=' , $ value , $ conjunction ) ) ; }
Asserts that the column is not equal to the value
35,098
public function greater ( $ column , $ value , $ conjunction = 'AND' ) { return $ this -> addExpression ( new Condition \ Basic ( $ column , '>' , $ value , $ conjunction ) ) ; }
Asserts that the column is greater then the value
35,099
public function greaterThen ( $ column , $ value , $ conjunction = 'AND' ) { return $ this -> addExpression ( new Condition \ Basic ( $ column , '>=' , $ value , $ conjunction ) ) ; }
Asserts that the column is greater or equal to the value