ayman

Experience

19,410

0 Best Reply Awards

  • Member Since 1 Year Ago
  • 187 Lessons Completed
  • 7 Favorites

24th September, 2017

ayman started a new conversation I'm Looking For Schema "snappy" And "soda" Theme For Phpstorm • 1 month ago

I'm looking for color scheme (snappy-light (SL).tmTheme)[http://daylerees.github.io/] and theme (Soda Light 3.sublime-theme)[http://buymeasoda.github.io/soda-theme/] any suggest to phpstorm

18th September, 2017

ayman started a new conversation Closure How To Get Parameters Value NOT Name • 2 months ago

I have closure question? how to get parameters value NOT name

class Foo {
    public function send($message){
        if (is_callback($message)){
            // I need to get $via value to execute some behaviours 
            $message = call_user_func($message);
        }
    }
}

(new Foo)->send(function($via = ['mail', 'sms']) { return 'message to'; })

14th September, 2017

ayman left a reply on How To Test That Simple Case? With Mockery • 2 months ago

I got an error Method Mockery_0__Foo::m1() does not exist on this mock object

    public function testM1()
    {
        $foo = Mockery::mock('Foo')->makePartial();
        $foo->shouldReceive('m2')->once()->andReturn('diff');
        $this->assertEquals('diff', $foo->m1());
    }
class Foo {
    public function m1(){
        return $this->m2();
    }

    private function m2() {
        return 'm2';
    }
}

13th September, 2017

ayman started a new conversation How To Test That Simple Case? With Mockery • 2 months ago

How to test that simple case?

class Foo {
    
    public function m1(){
        // some code
        $result = $this->m2();
        // some code
    }

    private function m2() {
        return 'm2';
    }
}

I need to test m1 and stubs m2 instead of return 'm2' return different value

I use Mockery

8th February, 2017

ayman started a new conversation How Test That Class ? • 9 months ago

Well, let's say I have class Builder with only two functions

str_random that returns random string

make that takes string and adding what values return from str_random;

how really could test that class .

<?php

namespace My\NameSpace;

class Builder {
    
    public function str_random(){

        return 'random string'//
    }

    public function make($value) {
        $str = $this->str_random();

        return $str.$value;
    }
}
class BuilderTest extends PHPUnit_Framework_TestCase
{
   /** @tests */
    public function make()
    {
        $builder = new My\NameSpace\Builder;

        $hash = $builder->make('hi');

        $this->assertEquals($hash, "what ?");
    }
}

I think let's not test class it self but new instance after overriding str_random function

class Builder extends BaseBuilder {    
    public function str_random(){
        return 'no random';
    }
}

now we can test

/** @tests */
public function make()
{
    $builder = new My\NameSpace\Builder;

    $hash = $builder->make('hi');

    $this->assertEquals($hash, "hi no random");
}

Is it that best practice ?

25th January, 2017

ayman left a reply on How To Set Timeout For Question In Artisan Command • 9 months ago

thank you w1n78. I found an option with artisan command

--no-interaction Do not ask any interactive question

in my case it's okay

24th January, 2017

ayman started a new conversation How To Set Timeout For Question In Artisan Command Let's Say We Have Artisan Command ``` $this->ask('How Is It Going?', 'good') ``` If User Doesn't Answer Within Time Take Default Answer And Continue To The Next Line ... • 9 months ago

How to set timeout for question in artisan command

let's say we have artisan command

    $this->ask('How is it going?', 'good')

If user doesn't answer within time take default answer and continue to the next line ...

23rd January, 2017

ayman left a reply on How To Access .env Inside Envoy.blade.php • 9 months ago

I got Call to undefined function config()

Laravel Framework version 5.1.41

ayman started a new conversation How To Access .env Inside Envoy.blade.php • 9 months ago

How to access the .env inside Envoy.blade.php

Envoy.blade.php

@task('install')
    
    @if(env('FOO', false))
        
    @endif 

@endtask

I got Call to undefined function env()

29th December, 2016

ayman started a new conversation Is There A Function To Filter QueryLog By Type, Table • 10 months ago

Hi,

when you use DB::getQueryLog() it returns array of queries

is there a function to filter them by type, table

DB::getQueryLog($table, $type)

28th December, 2016

ayman left a reply on Is There A Function Return Full Query Statement Without Bindings • 10 months ago

Thank you but really I didn't mean that :)

I mean replace ? with value

update `services` set `name` = 'new name', `updated_at` = '2016-12-28 11:43:46'  where `id` =   1

ayman started a new conversation Is There A Function Return Full Query Statement Without Bindings • 10 months ago

DB::getQueryLog() return array contains query, bindings and time

{
"query": "update `service` set `name` = ?, `updated_at` = ? where `id` =    ?",
"bindings": [
    new name,
    "2016-12-28 11:43:46",
    1
],
"time": 4.88
}

Is there a function return full query statement without bindings

update `service` set `name` = 'new name', `updated_at` = '2016-12-28 11:43:46' ? where `id` =   1

27th December, 2016

ayman left a reply on Instead Of Passing Connection Name Pass Array Of Connection Setup • 10 months ago

I thought It couldn't change config on fly

ayman started a new conversation Instead Of Passing Connection Name Pass Array Of Connection Setup • 10 months ago

Hi I wanna connect with other database and for a reason I couldn't put database connections setup in config/database so instead of passing connection name pass array of connection setup

$target = DB::connection('target');

use

// db connection setup
$target = [] ;

$target = DB::connection($target); 

thanks

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.