idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
200 | public function addInline ( $ content , $ type , $ group = 'head' , $ slot = 'inline' ) { if ( ! isset ( $ this -> assets [ $ group ] ) ) $ this -> assets [ $ group ] = array ( ) ; if ( ! isset ( $ this -> assets [ $ group ] [ $ type ] ) ) $ this -> assets [ $ group ] [ $ type ] = array ( ) ; $ this -> assets [ $ group... | add inline script or styles |
201 | public function addNode ( $ node ) { $ src = false ; if ( array_key_exists ( 'src' , $ node ) ) $ src = $ node [ 'src' ] ; elseif ( array_key_exists ( 'href' , $ node ) ) $ src = $ node [ 'href' ] ; if ( $ src ) { if ( ! isset ( $ node [ 'type' ] ) ) { if ( preg_match ( '/.*\.(css|js)(?=[?#].*|$)/i' , $ src , $ match )... | push new asset during template execution |
202 | function parseNode ( $ node ) { $ src = false ; $ params = array ( ) ; if ( isset ( $ node [ '@attrib' ] ) ) { $ params = $ node [ '@attrib' ] ; unset ( $ node [ '@attrib' ] ) ; } if ( array_key_exists ( 'src' , $ params ) ) $ src = $ params [ 'src' ] ; elseif ( array_key_exists ( 'href' , $ params ) ) $ src = $ params... | parse node data on template compiling |
203 | function resolveAttr ( array $ attr ) { $ out = '' ; foreach ( $ attr as $ key => $ value ) { if ( preg_match ( '/{{(.+?)}}/s' , $ value ) ) $ value = $ this -> template -> build ( $ value ) ; if ( preg_match ( '/{{(.+?)}}/s' , $ key ) ) $ key = $ this -> template -> build ( $ key ) ; if ( is_numeric ( $ key ) ) $ out ... | general bypass for unhandled tag attributes |
204 | public function actionCreate ( ) { $ stdout = '' ; foreach ( $ this -> db -> schema -> getTableSchemas ( ) as $ table ) { if ( $ table -> name === $ this -> migrationTable ) { continue ; } $ stdout .= static :: generateCreateTable ( $ table -> name ) . static :: generateColumns ( $ table -> columns , $ this -> db -> sc... | Generates the createTable code . |
205 | public function actionDrop ( ) { $ stdout = '' ; foreach ( $ this -> db -> schema -> getTableSchemas ( ) as $ table ) { if ( $ table -> name === $ this -> migrationTable ) { continue ; } $ stdout .= static :: generateDropTable ( $ table -> name ) ; if ( ! empty ( $ table -> foreignKeys ) ) { $ stdout .= ' // fk: ' ; fo... | Generates the dropTable code . |
206 | private static function generateColumns ( array $ columns , array $ unique ) { $ definition = '' ; foreach ( $ columns as $ column ) { $ tmp = sprintf ( " '%s' => \$this->%s%s,\n" , $ column -> name , static :: getSchemaType ( $ column ) , static :: other ( $ column , $ unique ) ) ; if ( null !== $ column -> enumVal... | Returns the columns definition . |
207 | private static function generatePrimaryKey ( array $ pk , array $ columns ) { if ( empty ( $ pk ) ) { return '' ; } if ( 2 <= count ( $ pk ) ) { $ compositePk = implode ( ', ' , $ pk ) ; return " 'PRIMARY KEY ($compositePk)',\n" ; } $ flag = false ; foreach ( $ columns as $ column ) { if ( $ column -> autoIncrement ... | Returns the primary key definition . |
208 | private function generateForeignKey ( $ table ) { if ( empty ( $ table -> foreignKeys ) ) { return ; } $ definition = "// fk: $table->name\n" ; foreach ( $ table -> foreignKeys as $ fk ) { $ refTable = '' ; $ refColumns = '' ; $ columns = '' ; foreach ( $ fk as $ k => $ v ) { if ( 0 === $ k ) { $ refTable = $ v ; } els... | Returns the foreign key definition . |
209 | private static function getSchemaType ( $ column ) { if ( $ column -> isPrimaryKey && $ column -> autoIncrement ) { if ( 'bigint' === $ column -> type ) { return 'bigPrimaryKey()' ; } return 'primaryKey()' ; } if ( 'tinyint(1)' === $ column -> dbType ) { return 'boolean()' ; } if ( 'smallint' === $ column -> type ) { i... | Returns the schema type . |
210 | private static function other ( $ column , array $ unique ) { $ definition = '' ; if ( null !== $ column -> scale && 0 < $ column -> scale ) { $ definition .= "($column->precision,$column->scale)" ; } elseif ( null !== $ column -> size && ! $ column -> autoIncrement && 'tinyint(1)' !== $ column -> dbType ) { $ definiti... | Returns the other definition . |
211 | private function byOption ( ) { $ option = new OptionForCli ( $ this -> interactor ) ; $ option -> setOption ( $ this -> option ) ; $ option -> execute ( ) ; } | Download by option . |
212 | public function add ( $ input_data ) { $ data [ 'inputs' ] = [ ] ; if ( is_array ( $ input_data ) ) { foreach ( $ input_data as $ image ) { $ data [ 'inputs' ] [ ] = $ this -> addNewImage ( $ image ) ; } } else { $ data [ 'inputs' ] [ ] = $ this -> addNewImage ( $ input_data ) ; } $ inputResult = $ this -> getRequest (... | Add Input Method |
213 | public function addNewImage ( Input $ image ) { $ data = [ ] ; $ data [ 'data' ] = [ 'image' => $ this -> generateImageAddress ( $ image -> getImage ( ) , $ image -> getImageMethod ( ) ) , ] ; if ( $ image -> getId ( ) ) { $ data = $ this -> addImageId ( $ data , $ image -> getId ( ) ) ; } if ( $ image -> getCrop ( ) )... | Adds new Image to Custom Input |
214 | public function generateImageAddress ( string $ image , $ method = null ) { if ( $ method == Input :: IMG_BASE64 ) { return [ 'base64' => $ image ] ; } elseif ( $ method == Input :: IMG_PATH ) { if ( ! file_exists ( $ image ) ) { throw new FileNotFoundException ( $ image ) ; } return [ 'base64' => base64_encode ( file_... | Generate Image With Download Type |
215 | public function addImageConcepts ( array $ data , array $ concepts ) { $ data [ 'concepts' ] = [ ] ; foreach ( $ concepts as $ concept ) { $ data [ 'concepts' ] [ ] = [ 'id' => $ concept -> getId ( ) , 'value' => $ concept -> getValue ( ) , ] ; } return $ data ; } | Adds Image Concepts to Image Data |
216 | public function addImageMetadata ( array $ data , array $ metadata ) { $ data [ 'metadata' ] = [ ] ; foreach ( $ metadata as $ meta_name => $ meta_value ) { $ data [ 'metadata' ] [ $ meta_name ] = $ meta_value ; } return $ data ; } | Adds Image Metadaya to Image Data |
217 | public function get ( ) { $ inputResult = $ this -> getRequest ( ) -> request ( 'GET' , $ this -> getRequestUrl ( 'inputs' ) ) ; return $ this -> getInputsFromResult ( $ inputResult ) ; } | Gets All Inputs |
218 | public function getById ( $ id ) { $ inputResult = $ this -> getRequest ( ) -> request ( 'GET' , $ this -> getRequestUrl ( sprintf ( 'inputs/%s' , $ id ) ) ) ; if ( isset ( $ inputResult [ 'input' ] ) ) { $ input = new Input ( $ inputResult [ 'input' ] ) ; } else { throw new \ Exception ( 'Input Not Found' ) ; } return... | Gets Input By Id |
219 | public function getStatus ( ) { $ statusResult = $ this -> getRequest ( ) -> request ( 'GET' , $ this -> getRequestUrl ( 'inputs/status' ) ) ; if ( isset ( $ statusResult [ 'counts' ] ) ) { $ status = $ statusResult [ 'counts' ] ; } else { throw new \ Exception ( 'Status Not Found' ) ; } return $ status ; } | Gets Status of your Inputs |
220 | public function deleteById ( $ id ) { $ deleteResult = $ this -> getRequest ( ) -> request ( 'DELETE' , $ this -> getRequestUrl ( sprintf ( 'inputs/%s' , $ id ) ) ) ; return $ deleteResult [ 'status' ] ; } | Deletes Input By Id |
221 | public function deleteByIdArray ( array $ ids ) { $ data [ 'ids' ] = $ ids ; $ deleteResult = $ this -> getRequest ( ) -> request ( 'DELETE' , $ this -> getRequestUrl ( 'inputs' ) , $ data ) ; return $ deleteResult [ 'status' ] ; } | Deletes Inputs By Id Array |
222 | public function updateInputConcepts ( array $ conceptsArray , $ action ) { $ data [ 'inputs' ] = [ ] ; foreach ( $ conceptsArray as $ inputId => $ inputConcepts ) { $ input = [ ] ; $ input [ 'id' ] = ( string ) $ inputId ; $ input [ 'data' ] = [ ] ; $ input [ 'data' ] = $ this -> addImageConcepts ( $ input [ 'data' ] ,... | Common Input s Concepts Update Method |
223 | public function load ( ) { if ( empty ( $ this -> storage ) ) { throw new Exception ( 'Empty config storage' ) ; } $ storage = $ this -> getStorage ( ) ; $ storage -> load ( ) ; return $ this -> fromArray ( $ storage -> get ( ) ) ; } | Loads config from storage |
224 | protected function checkRequired ( ) { $ errors = new Exceptions ( ) ; foreach ( $ this -> getRequiredKeys ( ) as $ required ) { if ( ! isset ( $ this -> $ required ) ) { $ errors -> add ( new Exception ( 'Required property "' . $ required . '" is missing' ) ) ; } } if ( ! $ errors -> empty ( ) ) { throw $ errors ; } r... | Checks if all required properties are set |
225 | public function createHelpMessage ( ) { $ m = 'Usage:' . PHP_EOL ; $ m .= ' -h,--help' . PHP_EOL ; $ m .= ' Display help message and exit.' . PHP_EOL ; $ m .= ' -p platform (required)' . PHP_EOL ; $ m .= ' Select platform [m]ac or [w]indows or [l]inux.' . PHP_EOL ; $ m .= ' Required except that "--help, -h" ... | Create help message . |
226 | private function _getopt ( ) { $ shortopts = OptionConfig :: HELP ; $ shortopts .= OptionConfig :: PLATFORM . ':' ; $ shortopts .= OptionConfig :: OUTPUT_DIR . ':' ; $ shortopts .= OptionConfig :: SELENIUM_VER . ':' ; $ shortopts .= OptionConfig :: CHROME_DRIVER_VER . ':' ; $ shortopts .= OptionConfig :: GECKO_DRIVER_V... | Acquire command line option . |
227 | public function getRegisteredParsers ( ) { if ( $ this -> parserInstances === null ) { $ result = [ ] ; foreach ( $ this -> parsers as $ parser ) { if ( $ parser instanceof ParserInterface ) { $ result [ ] = $ parser ; } else { $ instance = $ this -> app -> make ( $ parser ) ; if ( ! ( $ instance instanceof ParserInter... | Get the list of registered parsers . |
228 | public function showShareButtons ( Twig_Environment $ twigEnvironment , array $ options = array ( ) , array $ providers = array ( ) ) { $ this -> shareButtonsRenderer -> setTemplateEngine ( $ twigEnvironment ) ; if ( isset ( $ providers ) ) { $ options [ 'providers' ] = $ providers ; } if ( ! isset ( $ options [ 'templ... | Renders share buttons bar template based on user settings . |
229 | public static function getFile ( $ tmp = true , $ name = null ) { return ( $ tmp ? realpath ( sys_get_temp_dir ( ) ) : '' ) . '/' . ( null === $ name ? uniqid ( ) : $ name ) ; } | Gets the file . |
230 | public function setAuthorizationFlow ( $ name , $ flow , $ authorizationUrl , $ tokenUrl , $ refreshUrl = null , array $ scopes = null ) { if ( ! isset ( $ this -> authFlows [ $ name ] ) ) { $ this -> authFlows [ $ name ] = [ ] ; } $ this -> authFlows [ $ name ] [ ] = [ $ flow , $ authorizationUrl , $ tokenUrl , $ refr... | Configuration details for a supported OAuth Flow |
231 | private static function decode ( $ data ) { if ( ( is_array ( $ data ) && isset ( $ data [ 0 ] ) ) || ( isset ( $ data [ 0 ] ) && ! is_string ( $ data [ 0 ] ) ) ) { return self :: parseArray ( $ data ) ; } else if ( is_null ( $ data ) || is_scalar ( $ data ) ) { return $ data ; } else { return self :: decodeNewObject (... | Decode Array collection |
232 | protected function getVolatileDirectory ( ) { if ( $ this -> volatileDirectory === null ) { $ this -> volatileDirectory = $ this -> app -> make ( VolatileDirectory :: class ) ; } return $ this -> volatileDirectory ; } | Get the volatile instance that contains the decompressed contents of the package archive . |
233 | public function repack ( ) { $ this -> extract ( ) ; try { $ this -> app -> make ( 'helper/zip' ) -> zip ( $ this -> getVolatileDirectory ( ) -> getPath ( ) , $ this -> packageArchive , [ 'includeDotFiles' => true ] ) ; } catch ( \ Exception $ x ) { throw new UserMessageException ( $ x -> getMessage ( ) ) ; } } | Re - create the source archive with the contents of the extracted directory . |
234 | public function format ( $ user ) { $ id = null ; $ name = '' ; $ userInfo = null ; if ( isset ( $ user ) && $ user ) { if ( is_int ( $ user ) || ( is_string ( $ user ) && is_numeric ( $ user ) ) ) { $ user = \ User :: getByUserID ( $ user ) ; } try { if ( $ user instanceof ConcreteUser && $ user -> getUserID ( ) && $ ... | Format a username . |
235 | public function getStickyRequest ( ) { if ( $ this -> stickyRequest === null ) { $ this -> stickyRequest = $ this -> app -> make ( StickyRequest :: class , [ 'community_translation.packages' ] ) ; } return $ this -> stickyRequest ; } | Get the instance of a class that holds the criteria of the last performed search . |
236 | public function getSearchList ( ) { if ( $ this -> searchList === null ) { $ this -> searchList = $ this -> app -> make ( SearchList :: class , [ $ this -> getStickyRequest ( ) ] ) ; } return $ this -> searchList ; } | Get the instance of a class that defines the search list . |
237 | public function getByHandle ( $ handle ) { return isset ( $ this -> converters [ $ handle ] ) ? $ this -> converters [ $ handle ] : null ; } | Get a converter given its handle . |
238 | public function getByFileExtension ( $ fileExtension ) { $ fileExtension = ltrim ( $ fileExtension ) ; $ result = [ ] ; foreach ( $ this -> converters as $ converter ) { if ( strcasecmp ( $ fileExtension , $ converter -> getFileExtension ( ) ) === 0 ) { $ result [ ] = $ converter ; } } return $ result ; } | Get the converter given a file extension . |
239 | public function getRegisteredConverters ( ) { $ result = $ this -> converters ; $ comparer = new Comparer ( ) ; usort ( $ result , function ( ConverterInterface $ a , ConverterInterface $ b ) use ( $ comparer ) { return $ comparer -> compare ( $ a -> getName ( ) , $ b -> getName ( ) ) ; } ) ; return $ result ; } | Get the list of registered converters . |
240 | public function filterByKeywords ( $ name ) { $ likeBuilder = $ this -> app -> make ( LikeBuilder :: class ) ; $ likes = $ likeBuilder -> splitKeywordsForLike ( $ name , '\W_' ) ; if ( ! empty ( $ likes ) ) { $ expr = $ this -> query -> expr ( ) ; $ orFields = $ expr -> orX ( ) ; foreach ( [ 'p.handle' , 'p.name' ] as ... | Filter the results by keywords . |
241 | protected function doRender ( array $ options ) { if ( ! isset ( $ this -> templateEngine ) ) { throw new InvalidArgumentException ( 'Missing template engine' ) ; } if ( ! isset ( $ this -> label ) ) { throw new InvalidArgumentException ( 'Missing provider label' ) ; } if ( isset ( $ options [ $ this -> label ] ) ) { $... | Performs share button rendering . |
242 | public function addVisit ( $ type , $ count = 1 , DateTime $ dateTime = null , AddressInterface $ ipAddress = null ) { $ count = ( int ) $ count ; if ( $ count > 0 ) { if ( $ dateTime === null ) { $ dateTime = new DateTime ( ) ; } if ( $ ipAddress === null ) { $ ipAddress = $ this -> getIPAddress ( ) ; } $ this -> conn... | Count a visit for a specified type . |
243 | public static function create ( $ domain , $ whois ) { $ tld = substr ( strrchr ( $ domain , '.' ) , 1 ) ; $ parserClass = 'Wisdom\\Whois\\Parser\\Tld\\' . ucfirst ( $ tld ) ; if ( ! class_exists ( $ parserClass ) ) { throw new WhoisParserNotFoundException ( sprintf ( 'Whois parser for .%s domains not found.' , $ tld )... | Creates whois parser for given domain name . |
244 | public static function getCurrentArch ( ) : string { $ arch = php_uname ( 'm' ) ; if ( $ arch === "x86_64" ) { $ arch = "amd64" ; } elseif ( $ arch === "i386" ) { $ arch = "386" ; } else { printf ( 'ERROR: Unexpected, please contact the maintainer or provide a pull request :)%s' , PHP_EOL ) ; exit ( 1 ) ; } return $ ar... | Returns the architecture of the current machine |
245 | public static function getBinaryPath ( ) : string { $ binaryName = Utilities :: getReleaseName ( ) ; $ binaryPath = sprintf ( '%s/bin/%s' , Utilities :: getBasePath ( ) , $ binaryName ) ; return $ binaryPath ; } | returns the binary name |
246 | public static function downloadReleaseArchive ( string $ releaseName , string $ version ) : bool { $ archiveName = $ releaseName . '.tar.gz' ; $ archivePath = sprintf ( '%s/%s' , Utilities :: getBasePath ( ) , $ archiveName ) ; $ releaseUrl = sprintf ( 'https://github.com/editorconfig-checker/editorconfig-checker/relea... | Downloads the release from the release page |
247 | public static function extractReleaseArchive ( string $ releaseName ) : bool { return Utilities :: decompress ( $ releaseName ) && Utilities :: unpack ( $ releaseName ) ; } | decompresses and extracts the release archive |
248 | public static function decompress ( string $ releaseName ) : bool { try { $ p = new \ PharData ( sprintf ( "%s/%s.tar.gz" , Utilities :: getBasePath ( ) , $ releaseName ) ) ; $ p -> decompress ( ) ; } catch ( Exception $ e ) { printf ( 'ERROR: Can not decompress the archive%s%s' , PHP_EOL , $ e ) ; return false ; } ret... | decompresses the release archive |
249 | public static function unpack ( string $ releaseName ) : bool { try { $ p = new \ PharData ( sprintf ( "%s/%s.tar" , Utilities :: getBasePath ( ) , $ releaseName ) ) ; $ p -> extractTo ( Utilities :: getBasePath ( ) ) ; if ( ! unlink ( sprintf ( "%s/%s.tar" , Utilities :: getBasePath ( ) , $ releaseName ) ) ) { printf ... | unpacks the release archive |
250 | public static function constructStringFromArguments ( array $ arguments ) : string { $ result = '' ; foreach ( $ arguments as $ argument ) { $ result .= ' ' . $ argument ; } return $ result ; } | Constructs the arguments the binary needs to be called by the arguments providedunline |
251 | public static function cleanup ( ) : void { $ releaseName = sprintf ( "%s/%s" , Utilities :: getBasePath ( ) , Utilities :: getReleaseName ( ) ) ; if ( is_file ( $ releaseName . '.tar.gz' ) ) { unlink ( $ releaseName . '.tar.gz' ) ; } if ( is_file ( $ releaseName . '.tar' ) ) { unlink ( $ releaseName . '.tar' ) ; } } | Removes all intermediate files |
252 | public function setTopic ( $ value ) { $ this -> assertValidString ( $ value , false ) ; if ( $ value === '' ) { throw new \ InvalidArgumentException ( 'The topic must not be empty.' ) ; } $ this -> topic = $ value ; } | Sets the topic . |
253 | public function processParameters ( ) { $ parameters = $ this -> getParameters ( ) ; $ factory = $ this -> buildFactory ( ) ; $ parametersType = $ this -> buildParametersType ( ) ; $ request = $ factory -> create ( $ parametersType ) ; if ( ! is_null ( $ parameters ) ) { $ processorFactory = new ParametersProcessorFact... | Fonction de process pour les parametres |
254 | public function getAttributes ( ) { $ defaultPrefix = PhoneNumber :: config ( ) -> get ( 'default_country_code' ) ; $ attributes = [ 'class' => 'text' , 'placeholder' => _t ( __CLASS__ . '.Placeholder' , 'Phone number links will be prefixed with +{prefix}' , [ 'prefix' => $ defaultPrefix ] ) , ] ; return array_merge ( ... | Return field attributes |
255 | public function matches ( $ filter , $ topic ) { $ tokens = explode ( '/' , $ filter ) ; $ parts = [ ] ; for ( $ i = 0 , $ count = count ( $ tokens ) ; $ i < $ count ; ++ $ i ) { $ token = $ tokens [ $ i ] ; switch ( $ token ) { case '+' : $ parts [ ] = '[^/#\+]*' ; break ; case '#' : if ( $ i === 0 ) { $ parts [ ] = '... | Check if the given topic matches the filter . |
256 | protected function log ( $ message , $ context ) { $ logger = $ this -> getLogger ( ) ; if ( $ logger !== null ) { $ logger -> error ( $ message , $ context ) ; } } | Curl operation error logging function |
257 | private function readRemainingLength ( PacketStream $ stream ) { $ this -> remainingPacketLength = 0 ; $ multiplier = 1 ; do { $ encodedByte = $ stream -> readByte ( ) ; $ this -> remainingPacketLength += ( $ encodedByte & 127 ) * $ multiplier ; $ multiplier *= 128 ; if ( $ multiplier > 128 * 128 * 128 * 128 ) { throw ... | Reads the remaining length from the given stream . |
258 | private function writeRemainingLength ( PacketStream $ stream ) { $ x = $ this -> remainingPacketLength ; do { $ encodedByte = $ x % 128 ; $ x = ( int ) ( $ x / 128 ) ; if ( $ x > 0 ) { $ encodedByte |= 128 ; } $ stream -> writeByte ( $ encodedByte ) ; } while ( $ x > 0 ) ; } | Writes the remaining length to the given stream . |
259 | protected function assertPacketFlags ( $ value , $ fromPacket = true ) { if ( $ this -> packetFlags !== $ value ) { $ this -> throwException ( sprintf ( 'Expected flags %02x but got %02x.' , $ value , $ this -> packetFlags ) , $ fromPacket ) ; } } | Asserts that the packet flags have a specific value . |
260 | protected function assertRemainingPacketLength ( $ value = null , $ fromPacket = true ) { if ( $ value === null && $ this -> remainingPacketLength === 0 ) { $ this -> throwException ( 'Expected payload but remaining packet length is zero.' , $ fromPacket ) ; } if ( $ value !== null && $ this -> remainingPacketLength !=... | Asserts that the remaining length is greater than zero and has a specific value . |
261 | protected function assertValidQosLevel ( $ level , $ fromPacket = true ) { if ( $ level < 0 || $ level > 2 ) { $ this -> throwException ( sprintf ( 'Expected a quality of service level between 0 and 2 but got %d.' , $ level ) , $ fromPacket ) ; } } | Asserts that the given quality of service level is valid . |
262 | public static function run ( array $ arguments ) : int { $ releaseName = Utilities :: getReleaseName ( ) ; $ binaryPath = Utilities :: getBinaryPath ( ) ; if ( ! is_file ( $ binaryPath ) ) { Utilities :: cleanup ( ) ; if ( ! Utilities :: downloadReleaseArchive ( $ releaseName , CORE_VERSION ) ) { printf ( 'ERROR: Can n... | Entry point of this class to invoke all needed steps |
263 | protected function applyCasts ( bool $ scalarOnly = false ) : void { if ( ! $ scalarOnly ) { foreach ( array_keys ( $ this -> casts ( ) ) as $ key ) { $ this -> applyCast ( $ key ) ; } return ; } foreach ( $ this -> casts ( ) as $ key => $ type ) { if ( ! in_array ( $ type , static :: SCALAR_CASTS ) ) { continue ; } $ ... | Applies casts to currently set attributes . |
264 | protected function applyCast ( string $ key ) : void { $ casts = $ this -> casts ( ) ; if ( ! count ( $ casts ) || ! array_key_exists ( $ key , $ casts ) ) { return ; } if ( ! isset ( $ this -> attributes [ $ key ] ) ) { $ value = null ; } else { $ value = $ this -> attributes [ $ key ] ; } if ( in_array ( $ casts [ $ ... | Applies cast for a given attribute key . |
265 | protected function makeNestedDataObject ( string $ class , $ data , $ key ) : DataObjectInterface { $ data = ( $ data instanceof Arrayable ) ? $ data -> toArray ( ) : $ data ; if ( ! is_array ( $ data ) ) { throw new UnexpectedValueException ( "Cannot instantiate data object '{$class}' with non-array data for key '{$ke... | Makes a new nested data object for a given class and data . |
266 | public function getNextValue ( string $ sequenceName ) : int { $ sequenceValue = $ this -> rawCollection ( ) -> findOneAndUpdate ( [ '_id' => $ sequenceName ] , [ '$inc' => [ 'seq' => 1 ] ] , [ 'upsert' => true ] ) ; if ( $ sequenceValue ) { $ _id = $ sequenceValue -> seq + 1 ; } return $ _id ?? 1 ; } | Get next value for the sequence . |
267 | public function reduce ( $ degree , $ lookAhead = null ) { if ( $ lookAhead ) { $ this -> lookAhead = ( int ) $ lookAhead ; } $ epsilon = deg2rad ( $ degree ) ; $ results = array ( ) ; for ( $ i = 0 ; $ i < $ this -> count ( ) ; $ i ++ ) { $ j = min ( $ i + $ this -> lookAhead , $ this -> lastKey ( ) ) ; $ basePoint = ... | Reduce points with modified version of Zhao - Saalfeld simplification . |
268 | private function _theta ( PointInterface $ a , PointInterface $ b ) { list ( $ x1 , $ y1 ) = $ a -> getCoordinates ( ) ; list ( $ x2 , $ y2 ) = $ b -> getCoordinates ( ) ; return atan2 ( $ y2 - $ y1 , $ x2 - $ x1 ) + 2 * M_PI ; } | Calculate the angle and add 2pi to protect against underflow . |
269 | public function read ( $ count ) { $ contentLength = strlen ( $ this -> data ) ; if ( $ this -> position > $ contentLength || $ count > $ contentLength - $ this -> position ) { throw new EndOfStreamException ( sprintf ( 'End of stream reached when trying to read %d bytes. content length=%d, position=%d' , $ count , $ c... | Returns the desired number of bytes . |
270 | public function writeWord ( $ value ) { $ this -> write ( chr ( ( $ value & 0xFFFF ) >> 8 ) ) ; $ this -> write ( chr ( $ value & 0xFF ) ) ; } | Appends a single word . |
271 | public function cut ( ) { $ this -> data = substr ( $ this -> data , $ this -> position ) ; if ( $ this -> data === false ) { $ this -> data = '' ; } $ this -> position = 0 ; } | Removes all bytes from the beginning to the current position . |
272 | public static function where ( array $ query = [ ] , array $ projection = [ ] , bool $ useCache = false ) { return self :: getDataMapperInstance ( ) -> where ( $ query , $ projection , $ useCache ) ; } | Gets a cursor of this kind of entities that matches the query from the database . |
273 | public static function first ( $ query = [ ] , array $ projection = [ ] , bool $ useCache = false ) { return self :: getDataMapperInstance ( ) -> first ( $ query , $ projection , $ useCache ) ; } | Gets the first entity of this kind that matches the query . |
274 | public static function firstOrFail ( $ query = [ ] , array $ projection = [ ] , bool $ useCache = false ) { return self :: getDataMapperInstance ( ) -> firstOrFail ( $ query , $ projection , $ useCache ) ; } | Gets the first entity of this kind that matches the query . If no document was found throws ModelNotFoundException . |
275 | public static function firstOrNew ( $ id ) { if ( $ entity = self :: getDataMapperInstance ( ) -> first ( $ id ) ) { return $ entity ; } $ entity = new static ( ) ; $ entity -> _id = $ id ; return $ entity ; } | Gets the first entity of this kind that matches the query . If no document was found a new entity will be returned with the _if field filled . |
276 | public function getDataMapper ( ) { $ dataMapper = Ioc :: make ( DataMapper :: class ) ; $ dataMapper -> setSchema ( $ this -> getSchema ( ) ) ; return $ dataMapper ; } | Returns a DataMapper configured with the Schema and collection described in this entity . |
277 | protected function execute ( string $ action ) { if ( ! $ this -> getCollectionName ( ) ) { return false ; } $ options = [ 'writeConcern' => new WriteConcern ( $ this -> getWriteConcern ( ) ) , ] ; if ( $ result = $ this -> getDataMapper ( ) -> $ action ( $ this , $ options ) ) { $ this -> syncOriginalAttributes ( ) ; ... | Performs the given action into database . |
278 | private static function getDataMapperInstance ( ) { $ instance = Ioc :: make ( get_called_class ( ) ) ; if ( ! $ instance -> getCollectionName ( ) ) { throw new NoCollectionNameException ( ) ; } return $ instance -> getDataMapper ( ) ; } | Returns the a valid instance from Ioc . |
279 | protected function succeed ( $ result = null ) { $ this -> isFinished = true ; $ this -> isSuccess = true ; $ this -> result = $ result ; } | Marks the flow as successful and sets the result . |
280 | protected function fail ( $ error = '' ) { $ this -> isFinished = true ; $ this -> isSuccess = false ; $ this -> error = $ error ; } | Marks the flow as failed and sets the error message . |
281 | public static function isObjectId ( $ value ) { if ( is_object ( $ value ) && method_exists ( $ value , '__toString' ) ) { $ value = ( string ) $ value ; } return is_string ( $ value ) && 24 == strlen ( $ value ) && ctype_xdigit ( $ value ) ; } | Checks if the given value can be a valid ObjectId . |
282 | protected function getScriptPath ( ) : string { $ class = new \ ReflectionClass ( $ this -> getClassName ( ) ) ; $ path = $ class -> getFileName ( ) ; $ path = preg_replace ( '/\.php$/' , '.phtml' , $ path , - 1 , $ count ) ; if ( $ count !== 1 ) { throw new \ RuntimeException ( 'The class filename does not end with .p... | Returns the view script path . |
283 | protected function getTableValuesSelect ( $ dbm = null ) { $ dbm = $ dbm ? $ dbm : new DBM ; $ table_raw = $ dbm -> getTableList ( ) ; return $ table_raw ? array_combine ( array_values ( $ table_raw ) , array_values ( $ table_raw ) ) : false ; } | Return value with table names for a select |
284 | protected function getDataTable ( ) { $ data = $ this -> getTableData ( ) ; $ header = $ this -> getTableHeader ( ) ; $ table = new Table ( ) ; $ table -> setConfig ( array ( "table-hover" => true , "table-condensed" => false , "table-responsive" => true , "table-striped" => true , ) ) ; $ table -> setHeader ( $ header... | Return the table for the preview |
285 | protected function getTableData ( ) { $ data = array ( ) ; $ form_input = $ this -> getFormInput ( ) ; if ( $ form_input [ 'table_name' ] && $ form_input [ 'max_rows' ] ) { $ connection_name = Config :: get ( 'laravel-import-export::baseconf.connection_name' ) ; $ temp_data = DB :: connection ( $ connection_name ) -> t... | Get the data from the db for the preview |
286 | protected function getTableHeader ( $ dbm = null ) { $ dbm = $ dbm ? $ dbm : new DBM ; $ columns = array ( ) ; $ form_input = $ this -> getFormInput ( ) ; if ( $ form_input [ 'table_name' ] ) { $ dbal_columns = $ dbm -> getTableColumns ( $ this -> form_input [ 'table_name' ] ) ; foreach ( $ dbal_columns as $ column ) {... | Get the header for the preview |
287 | public function getTemporary ( ) { $ connection_name = Config :: get ( 'laravel-import-export::baseconf.connection_name' ) ; DB :: connection ( $ connection_name ) -> disableQueryLog ( ) ; $ temporary = TemporaryModel :: whereRaw ( "1" ) -> orderBy ( "id" , "DESC" ) -> first ( ) ; if ( $ temporary ) { $ this -> csv_fil... | Get data from the temporary table |
288 | public function saveTemporary ( $ csv_file = null , $ temporary_model = null ) { $ csv_file = $ csv_file ? $ csv_file : $ this -> csv_file ; if ( $ csv_file ) { $ temporary_model = ( $ temporary_model ) ? $ temporary_model : new TemporaryModel ( ) ; $ temporary_model -> fill ( array ( "file_object" => $ csv_file ) ) ; ... | Put data in the temporary table |
289 | public function updateHeaders ( CsvFile $ csv_file , array $ columns , $ table_name ) { $ this -> csv_file = $ csv_file ? $ csv_file : $ this -> csv_file ; foreach ( $ this -> csv_file as $ csv_line ) { $ this -> updateHeader ( $ csv_line , $ columns , $ table_name ) ; } } | Update headers of the csv_file |
290 | protected function updateHeader ( CsvLine $ csv_line , array $ columns , $ table_name ) { $ model_attributes = $ csv_line -> getAttributes ( ) ; $ new_attributes = array ( ) ; foreach ( $ columns as $ key_column => $ column ) { if ( isset ( $ model_attributes [ $ key_column ] ) ) { $ new_attributes = array_merge ( $ ne... | Update headers of the csv_line |
291 | public function openFromDb ( array $ config , DbFileBuilder $ builder = null ) { $ builder = $ builder ? $ builder : new DbFileBuilder ( ) ; $ builder -> setConfig ( $ config ) ; $ builder -> build ( ) ; $ this -> csv_file = $ builder -> getCsvFile ( ) ; return $ this -> getCsvFile ( ) ; } | Build the csvFile from Db |
292 | public function getMaxLength ( $ csv_file = null ) { $ csv_file = $ csv_file ? $ csv_file : $ this -> csv_file ; $ sizes = array ( 0 ) ; if ( ! $ csv_file ) { throw new NoDataException ( ) ; } foreach ( $ csv_file as $ line ) { $ sizes [ ] = count ( $ line -> getElements ( ) ) ; } return max ( $ sizes ) ; } | Get the max lenght of a csv_line |
293 | public function getCsvString ( $ separator , CsvFile $ csv_file = null ) { $ csv_file = $ csv_file ? $ csv_file : $ this -> csv_file ; $ csv = '' ; if ( ! isset ( $ csv_file ) ) { throw new NoDataException ; } else { foreach ( $ csv_file as $ key => $ csv_line ) { if ( $ key == 0 ) { $ csv .= $ csv_line -> getCsvHeader... | Create the csv string rappresenting the CsvFile |
294 | protected function updateCsvHeader ( ) { if ( $ this -> config [ 'first_line_headers' ] ) { $ csv_line_array = $ this -> csv_parser -> parseCsvFile ( ) ; $ this -> csv_file -> setCsvHeader ( $ csv_line_array ) ; } } | Update the csv header with first row of the file if first_line_headers is enabled |
295 | protected function generateIdentifier ( ) { if ( $ this -> identifier === null ) { ++ self :: $ nextIdentifier ; self :: $ nextIdentifier &= 0xFFFF ; $ this -> identifier = self :: $ nextIdentifier ; } return $ this -> identifier ; } | Returns the identifier or generates a new one . |
296 | public function setIdentifier ( $ value ) { if ( $ value !== null && ( $ value < 0 || $ value > 0xFFFF ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Expected an identifier between 0x0000 and 0xFFFF but got %x' , $ value ) ) ; } $ this -> identifier = $ value ; } | Sets the identifier . |
297 | public function approvedWithPending ( ) : ActiveQuery { return $ this -> andWhere ( [ $ this -> statusAttribute => [ Status :: APPROVED , Status :: PENDING ] ] ) ; } | Get a new active query object that includes approved and pending resources . |
298 | public function channel ( $ channel ) { if ( ! isset ( $ channel [ 'link' ] ) ) { $ channel [ 'link' ] = '/' ; } if ( ! isset ( $ channel [ 'title' ] ) ) { $ channel [ 'title' ] = '' ; } if ( ! isset ( $ channel [ 'description' ] ) ) { $ channel [ 'description' ] = '' ; } $ channel = $ this -> _prepareOutput ( $ channe... | Prepares the channel and sets default values . |
299 | public function render ( $ view = null , $ layout = null ) { if ( isset ( $ this -> viewVars [ '_serialize' ] ) ) { return $ this -> _serialize ( $ this -> viewVars [ '_serialize' ] ) ; } if ( $ view !== false && $ this -> _getViewFileName ( $ view ) ) { return parent :: render ( $ view , false ) ; } } | Render a RSS view . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.